tags:

views:

102

answers:

2
var store = new Ext.data.JsonStore({
                                                id:'jfields',
                                                totalProperty:'totalcount',
                                                root:'rows',
                                                url: 'data.php',  
                                                fields:[{ name:'jfields' },
                                                        { name:'firstyear' , mapping :'firstyear' , type:'float' },
                                                        { name:'secondyear', mapping :'secondyear', type:'float' },
                                                        { name:'thirdyear' , mapping :'thirdyear' , type:'float' },
                                                        { name:'fourthyear', mapping :'fourthyear', type:'float' },
                                                        { name:'fifthyear' , mapping :'fifthyear' , type:'float' } ]

                                                }                                                   
                                            });

what i want is to add data at the end for this store , but i am totally confused , what i did is i add the following code to it but not working.
listeners:{ load : function(){ BG_store.add([{"jfields":"Monthly","firstyear":22.99,"secondyear":21.88,"thirdyear":21.88,"fourthyear":22.99,"fifthyear":21.88}]); } But i do not think my concept are cleared ,Please any body show some way how to do it .

+1  A: 

You need to define a record type, create it and at it, e.g:

TaskLocation = Ext.data.Record.create([
    {name: "id", type: "string"},
    {name: "type", type: "string"},
    {name: "type_data", type: "string"},
    {name: "display_value", type: "string"}
]);

Then:

var record = new TaskLocation({
    id: Ext.id(),
    type: "city",
    type_data: "",
    display_value: "Brighton"
});

Then:

my_store.add(record);
my_store.commitChanges();

Remember by the time the data is in the store it's not in the same format as you sent it down but in Record objects instead.

Lloyd
thanyou very much LIoyd , also i have figure out a way i am adding my answer too ,Once again Thankyou very much
Extjs Commander
A: 

Hi guys , I have also figured out a simple solution to this ----> listeners:{ load: function( xstore , record , option ) { var u = new xstore.recordType({ jfields : 'monthly' }); xstore.insert(record.length, u); }

Here what i have to add is this listeners as when the data loads it will create the record type and u can add fields as data as many as u want

Extjs Commander