1 2 3 4 5 6 7 8 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 | //define the model Ext.define( 'COMBO.model.Country' , { extend: 'Ext.data.Model' , fields: [ 'code' , 'name' , 'continent' , 'region' , 'lifeExpectancy' , 'gnp' ] }); //define the store Ext.define( 'COMBO.store.LocalCountries' , { extend: 'Ext.data.Store' , model: 'COMBO.model.Country' , autoLoad: true , pageSize: 9999, proxy: { type: 'ajax' , url: 'CountryServlet' , reader: { type: 'json' , root: 'countries' , successProperty: 'success' }, }, listeners: { load: function () { //this sets the default value to USA after the store loads var combo = Ext.getCmp( 'countrySearchBox' ); this .add(Ext.create( 'COMBO.model.Country' , { code: 'MARS' , name: 'MARS Country' , continent: 'MARS' , region: 'NORTH' , lifeExpectancy: 9999, gnp: 99.99 }) ); combo.setValue( "MARS" ); } } }); |
All one can think and do in a short time is to think what one already knows and to do as one has always done!
ExtJs 4 add record to JSON store after loading data from server using Ajax Request
In the example below we have defined a model for country and have a JSON store for countries loaded using an Ajax request. After the JSON data is loaded from the server we add another record to the store.
No comments:
Post a Comment
NO JUNK, Please try to keep this clean and related to the topic at hand.
Comments are for users to ask questions, collaborate or improve on existing.