2010-07-23 11 views
0

在我的Rails應用程序中,我在http://github.com/linoj/gridify的幫助下設置了自己的管理員。這種方法非常有效,但有一個例外:HTML在表格視圖中渲染,使得單元格像瘋了似的。我使用從json的帶HTML到rails應用程序的jqgrid

white-space:nowrap; 

在我的CSS中,這有助於防止其他格式化問題。

我仍然需要可以擺脫的HTML它獲取到表之前或忽略它當表呈現(我認爲這是很難做到)

我已經是一個控制器和一個索引查看以產生用於我的網格:

在控制器:

def index 
statics = Static.find(:all) do 
    if params[:_search] == "true" 
    name =~ "%#{params[:name]}%" if params[:name].present? 
    content =~ "%#{params[:content]}%" if params[:content].present?      
    end 
    paginate :page => params[:page], :per_page => params[:rows]  
    order_by "#{params[:sidx]} #{params[:sord]}" 
end 

respond_to do |format| 
    format.html 
    format.json { render :json => statics.to_jqgrid_json([:id,:name,:content], params[:page], params[:rows], statics.total_entries) } 
end 
end 

在index.html.erb:

<%= jqgrid("Static Pages", "statics", "/admin/statics", 
[ 
{ :field => "id", :label => "ID", :width => 35, :resizable => false }, 
{ :field => "name", :label => "Name", :width => 100, :editable => true }, 
{ :field => "content", :label => "Content", :width => 800, :editable => true, :edittype => "textarea", :editoptions => { :rows => 20, :cols => 60 } } 
], { :add => true, :edit => true, :inline_edit => false, :delete => true, :edit_url => "/admin/statics/post_data" } 
) %> 

有沒有人有一個想法,我可以如何實現這一行動的HTML是逃脫/剝離...什麼最好?

回答

0

我猜這個問題不會飛,我承認我沒有找到一個難以置信的優雅方式來解決我的問題。爲了完整,這是有我在我的CSS做哪些事情顯示我想要的方式:我對作爲輸入數據的維護者過度使用它的BR標籤特別高興

td {height:22px;white-space:nowrap;overflow:hidden;} 
p {display:inline;} 
br {display:none;} 
h3 {display:inline;} 
... 

相關問題