How to add records in json-store

后端 未结 3 647
野的像风
野的像风 2021-02-01 09:24
var store = new Ext.data.JsonStore({
    id:\'jfields\',
    totalProperty:\'totalcount\',
    root:\'rows\',
    url: \'data.php\',  
    fields:[{ name:\'jfields\' },
         


        
3条回答
  •  不知归路
    2021-02-01 09:52

    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.

提交回复
热议问题