Class: Lipsiadmin::Ext::Store
- Defined in:
- lib/view/helpers/ext/store.rb
Overview
Generate a new Ext.data.GroupingStore
Examples:
var store = new Ext.data.GroupingStore({
reader: new Ext.data.JsonReader({
id:'id',
totalProperty:'count', root:'results',
fields:[{
name: "accounts.name"
},{
name: "accounts.categories.name"
},{
type: "date",
renderer: Ext.util.Format.dateRenderer(),
name: "accounts.date",
dateFormat: "c"
},{
type: "date",
renderer: Ext.util.Format.dateTimeRenderer(),
name: "accounts.datetime",
dateFormat: "c"
} ]}),
proxy: new Ext.data.HttpProxy({ url:'/backend/accounts.json' }),
remoteSort: true
});
grid.store do |store|
store.url "/backend/accounts.json"
store.add "accounts.name"
store.add "accounts.categories.name"
store.add "accounts.date", :type => :date
store.add "accounts.datetime", :type => :datetime
end
Instance Method Summary collapse
-
#add_field(name = nil, options = {}) ⇒ Object
Add fields to a Ext.data.JsonReader.
-
#fields(fields) ⇒ Object
This add automatically fields from an array.
-
#initialize(options = {}) {|_self| ... } ⇒ Store
constructor
:nodoc:.
-
#to_s ⇒ Object
Return the javascript for create a new Ext.data.GroupingStore.
-
#url(value) ⇒ Object
The url for getting the json data.
Methods inherited from Component
#add, #after, #before, #config, #config=, #get_var, #id, #method_missing, #on, #prefix=, #raise_error, #title, #un, #var, #with_output_buffer
Constructor Details
#initialize(options = {}) {|_self| ... } ⇒ Store
:nodoc:
40 41 42 43 44 45 46 |
# File 'lib/view/helpers/ext/store.rb', line 40 def initialize(={}, &block)#:nodoc: @fields = [] super("Ext.data.GroupingStore", ) remoteSort true if config[:remoteSort].blank? baseParams("_method" => "GET") if config[:baseParams].blank? yield self if block_given? end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Lipsiadmin::Ext::Component
Instance Method Details
#add_field(name = nil, options = {}) ⇒ Object
Add fields to a Ext.data.JsonReader
Examples:
{
type: "date",
renderer: Ext.util.Format.dateTimeRenderer(),
name: "accounts.datetime",
dateFormat: "c"
}
add "accounts.datetime", :type => :datetime
71 72 73 74 75 76 77 78 79 80 |
# File 'lib/view/helpers/ext/store.rb', line 71 def add_field(name=nil, ={})#:nodoc: [:name] = name if name case [:type] when :date then .merge!({ :type => "date", :dateFormat => "Y-m-d" }) when :time_to_date then .merge!({ :type => "date", :dateFormat => "c" }) when :datetime then .merge!({ :type => "date", :dateFormat => "c" }) end raise ComponentError, "You must provide a Name for all fields" if [:name].blank? @fields << Configuration.new() end |
#fields(fields) ⇒ Object
This add automatically fields from an array
54 55 56 |
# File 'lib/view/helpers/ext/store.rb', line 54 def fields(fields) fields.each { || add_field(nil, ) } end |
#to_s ⇒ Object
Return the javascript for create a new Ext.data.GroupingStore
83 84 85 86 87 88 89 90 |
# File 'lib/view/helpers/ext/store.rb', line 83 def to_s raise ComponentError, "You must provide the correct var the store." if get_var.blank? raise ComponentError, "You must provide the url for get the store data." if @url.blank? && config[:proxy].blank? raise ComponentError, "You must provide some fields for get build store." if @fields.blank? config[:proxy] = default_proxy if config[:proxy].blank? config[:reader] = default_reader if config[:reader].blank? super end |
#url(value) ⇒ Object
The url for getting the json data
49 50 51 |
# File 'lib/view/helpers/ext/store.rb', line 49 def url(value) @url = value end |