Class: ExtEditorgrid

Inherits:
ExtNode show all
Includes:
Magic::Store, Magic::Title
Defined in:
lib/extclasses/editorgrid.rb

Constant Summary collapse

@@ALIAS_CONFIG =
{
  :text => :title
}

Instance Attribute Summary

Attributes inherited from ExtNode

#childs, #config, #deep_lvl, #default_config, #parent, #xtype

Instance Method Summary collapse

Methods included from Magic::Title

included

Methods included from Magic::Store

included

Methods inherited from ExtNode

#add_child, #apply_config, before_to_extjs, #build_abstract_function, #child_of?, #child_of_form?, #collect_events, #collect_ref, #conv_id_to_label, #conv_id_to_name, #conv_id_to_ref, #do_alias_config, #do_layout, #find, #find_field_elements, #find_parent, #get_all_siblings, get_before_filters, #get_deep, get_events, get_refs, #has_child?, #is_field_element?, #override_config, #prepare_config, #remove_childs, #remove_config, reset_generator_config, #root?, set_generator_config, #set_parent

Constructor Details

#initialize(config, parent) ⇒ ExtEditorgrid

Returns a new instance of ExtEditorgrid.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/extclasses/editorgrid.rb', line 9

def initialize(config, parent)
   @default_config = {
     title: 'My Grid',
     frame: true,
     width: "auto",
     height: 200,
     clicksToEdit: 2,
     # enableHdMenu: false,
     enableColumnMove: false,
     columnLines: true,
     # TODO dummy store
     store: [],
     # style: "{ height: 100%; }",
     viewConfig: {
       forceFit: true 
     },
     columns: [
       {
         xtype: 'gridcolumn',
         dataIndex: 'string',
         header: 'String',
         sortable: true,
         width: 100,
         editor: {
           xtype: 'textfield'
         }
       },
       {
         xtype: 'numbercolumn',
         align: 'right',
         dataIndex: 'number',
         header: 'Number',
         sortable: true,
         width: 100,
         editor: {
           xtype: 'numberfield'
         }
       },
       {
         xtype: 'datecolumn',
         dataIndex: 'date',
         header: 'Date',
         sortable: true,
         width: 100,
         editor: {
           xtype: 'datefield'
         }
       },
       {
         xtype: 'booleancolumn',
         dataIndex: 'bool',
         header: 'Boolean',
         sortable: true,
         width: 100,
         editor: {
         xtype: 'checkbox',
           boxLabel: 'BoxLabel'
         }
       }
     ]
   }

	super("editorgrid", config, parent)	
end

Instance Method Details

#to_extjs(at_deep = 0) ⇒ Object



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/extclasses/editorgrid.rb', line 74

def to_extjs(at_deep = 0)
  # grid use child to another purpose, paging and toolbar columns
  
  # columns
  cols = []
  self.childs.each do |c|
    cols << c.to_extjs(at_deep) unless c.xtype.match(/column$/).nil?
  end
  @config.merge! :columns => cols unless cols.nil?
  
  toolbar = self.find("toolbar")
  @config.merge! :tbar => toolbar.to_extjs(at_deep + 1) if toolbar

  paging = self.find("paging")
  if paging
    paging.override_config :store => @config[:store]
    @config.merge! :bbar => paging.to_extjs(at_deep + 1)
  end

  # grid not allow to have items
  self.childs = []
  super(at_deep)
end