开发者

extJs Json Reader

开发者 https://www.devze.com 2023-01-03 05:32 出处:网络
Please help me with this problem. I\'m new in extJs and i need a little help. I have this code Ext.onReady(function() {

Please help me with this problem. I'm new in extJs and i need a little help. I have this code

Ext.onReady(function() {
 var datesStore = new Ext.data.JsonStore({
  start : 'StartTableDate',
  end : 'FinishTableDate',  
            autoLoad : true,
            proxy : new Ext.data.HttpProxy({
                url : 'dates.json',
                method:'GET'
            }),
            fields : [
                // 2 mandatory fields
                {name:'StartTableDate'},
                {name:'FinishTableDate'}
            ]
        });

// i want to pass to variable start si end the values from JSON
var start = 'Sta开发者_JAVA技巧rtTableDate';
var end = 'FinishTableDate';


If I understand you correctly, you want to get the values from the first record of a JsonStore and assign them to variables. If that's the case, then I think you want an event handler:

var datesStore = new Ext.data.JsonStore({
            proxy : new Ext.data.HttpProxy({
                url : 'dates.json',
                method:'GET'
            }),
            fields : ['StartTableDate','EndTableDate']
        });
datesStore.on('load',function(dataStore,records,options) {
    if (records.length > 0) {
        var start = records[0].get('StartTableDate');
        var end = records[0].get('FinishTableDate');
     }
},this);
0

精彩评论

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

关注公众号