lib/view/helpers/ext/grid.rb in lipsiadmin-3.4.2 vs lib/view/helpers/ext/grid.rb in lipsiadmin-4.0.0
- old
+ new
@@ -36,14 +36,26 @@
# columns.fields @column_store.column_fields
# end
# grid.bbar :store => grid.get_store, :pageSize => params[:limit]
# end
#
+ # # Returns:
+ # # var grid = new Ext.grid.EditorGridPanel({
+ # # clicksToEdit: 1,
+ # # ...
+ #
+ # page.grid :editable => true do |grid|
+ # grid.id "grid-posts"
+ # ...
+ #
class Grid < Component
+
def initialize(options={}, &block)#:nodoc:
# Call Super Class for initialize configuration
- super("Ext.grid.GridPanel", options)
+ @editable = options.delete(:editable)
+
+ super("Ext.grid.#{@editable ? 'EditorGridPanel' : 'GridPanel' }", options)
# Write default configuration if not specified
config[:plugins] ||= []
viewConfig :forceFit => true
clicksToEdit 1
@@ -253,10 +265,10 @@
raise_error "You must provide the selection model for autobuild toolbar." if config[:sm].blank?
raise_error "You must provide the store." if config[:store].blank?
end
if @default_tbar
- after << render_javascript(:grid_functions, :var => get_var, :store => config[:store], :sm => config[:sm], :tbar => config[:tbar])
+ after << render_javascript(:grid_functions, :var => get_var, :store => config[:store], :sm => config[:sm], :tbar => config[:tbar], :editable => @editable)
end
if config[:store]
after << "#{config[:store]}.on('beforeload', function(){ Backend.app.mask(); });"
after << "#{config[:store]}.on('load', function(){ Backend.app.unmask(); });"
\ No newline at end of file