Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Extjs 如何在sencha touch 2.3.0中创建网格从REST Web服务填充数据_Extjs_Sencha Touch 2 - Fatal编程技术网

Extjs 如何在sencha touch 2.3.0中创建网格从REST Web服务填充数据

Extjs 如何在sencha touch 2.3.0中创建网格从REST Web服务填充数据,extjs,sencha-touch-2,Extjs,Sencha Touch 2,我需要在Sencha Touch 2.3.0的网格/表格中显示报告。是否有任何内置功能来执行此操作。 存储区需要从REST webservice调用填充数据。要加载数据,可以使用REST代理配置 要显示存储区中的数据,您可以使用我一直在这样做: (虽然我没有使用网格,但我很确定同样的原则适用于…) 现在你的数据当然不会有“显示姓名、性别”等。。但你应该明白这一点 我在这里还找到了一个有效的例子(我发现Sencha允许在他们自己的网站上进行破坏性的演示,这让我非常难过):我仍然无法理解。非常感谢您

我需要在Sencha Touch 2.3.0的网格/表格中显示报告。是否有任何内置功能来执行此操作。
存储区需要从REST webservice调用填充数据。

要加载数据,可以使用REST代理配置


要显示存储区中的数据,您可以使用

我一直在这样做:

(虽然我没有使用网格,但我很确定同样的原则适用于…)

现在你的数据当然不会有“显示姓名、性别”等。。但你应该明白这一点


我在这里还找到了一个有效的例子(我发现Sencha允许在他们自己的网站上进行破坏性的演示,这让我非常难过):

我仍然无法理解。非常感谢您提供一个示例代码或一些链接。在我的回答中,您可以看到四个指向文档的链接,在这些链接中您还可以找到示例。在这里您可以找到详细的exmaple:有人可以分享一个相同的工作示例吗
Ext.define('App.controller.GridController', {
extend : 'Ext.app.Controller',
config: {
    refs: {
        getApiButton: 'button[action=getApiData]'
    },
    control: {
        'getApiButton' : {
            tap : 'onButtonTap'
        }
    }
},

onButtonTap : function(field, value) {

    var that = this;

    Ext.Ajax.request({
        url : someWebServiceUrl,
        method: 'GET',
        success: function (result, request) {

            var res = Ext.decode(result.responseText);

            if (res.success === true && res.data != false) {

                var recipient = {
                    name:   res.data[0].displayname,
                    picId:  res.data[0].pictureid,
                    gender: res.data[0].gender
                };

                var mod = Ext.define('App.model.GradingPopModel', {
                    extend: 'Ext.data.Model',
                    config: {
                        fields: [
                            'name',
                            'picId',
                            'gender'
                        ]
                    }
                });

                /* == this is probably where you want to make your changes to apply the model to the grid template
                      the sencha website has this:

                data: {'items': [
                    { 'name': 'Lisa',  "email":"lisa@simpsons.com",  "phone":"555-111-1224"  },
                    { 'name': 'Bart',  "email":"bart@simpsons.com",  "phone":"555-222-1234" },
                    { 'name': 'Homer', "email":"home@simpsons.com",  "phone":"555-222-1244"  },
                    { 'name': 'Marge', "email":"marge@simpsons.com", "phone":"555-222-1254"  }
                ]}

                */

                var store = Ext.create('Ext.data.Store', {
                    model: mod,
                    storeId:'recipStore'
                });

                store.add(recipient);
                store.setData(recipient);
                store.load();

                var gridView = Ext.ComponentQuery.query('#gridViewId')[0];

                gridView.setStore(store);

            }
        },
        failure: function (result, request) {
            console.log('api call was a failure');
        },
        scope: this
    });
}
});