开发者

Store's metadata won't load

I try to load fields config to json store via metadata. The json is:

{开发者_如何学Go
   "rows":[
      {
         "datev":"02.01.2011",
         "w1":"100",
         "w2":"200"
      },
      {
         "datev":"02.01.2011",
         "w1":"300",
         "w2":"50"
      },
      {
         "datev":"03.01.2011",
         "w1":"10",
         "w2":"450"
      }
   ],
   "metaData":{
      "fields":[
         {
            "name":"datev"
         }
      ],
      "root":"rows"
   }
}

and my store is:

var test = new Ext.data.JsonStore({
                  url: 'test.php'    
           });
test.load();

The metadata doesn't load. What is wrong with the code?


I think you need to add a JSON reader

var reader = new Ext.data.JsonReader({
        fields: []
});

var store = new Ext.data.Store({
   nocache : true,
   reader : reader,
   autoLoad : true,
   remoteSort : true,
   proxy : new Ext.data.HttpProxy({
       url : '/getjson?queryable=featureType&featureType=Electronic%20Device',
       method : 'GET'
   })

or maybe

var store = new Ext.data.JsonStore({
    url: 'somewhere',
    fields: []
});


You are not specifying the Id Property, and neither the Root property. this is my code i hope this help

var EStore = new Ext.data.JsonStore
    ({
      api: { read: 'getAssignedJobs',
             create: 'createAssignedJobs',
             update: 'updateAssignedJobs'
     },
     root: 'jobData',
     idProperty: 'Id',
     autoSave: true,
     batch: false,
     successProperty: 'success',
     writer: new Ext.data.JsonWriter({ encode: true, writeAllFields: true }),
     fields: [
        { name: 'Id', type: 'int' },
        { name: 'ResourceId', mapping: 'fitter_id', type: 'int' },
        { name: 'StartDate', type: 'date', format: 'd/m/Y G:i' },
        { name: 'EndDate', type: 'date', format: 'd/m/Y G:i' },
        { name: 'status', type: 'int' },
        { name: 'job_id', type: 'int' }
     ]
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜