如何使EXT JS模型和代理存储起作用? (请帮忙!)

时间:2018-10-25 08:46:13

标签: javascript extjs sencha-touch sencha-touch-2 extjs4.1

我还不了解如何使用REST API链接服务器数据和表单字段。

我有一些选择字段的表格。我对此有特别的价值在服务器上的字段。我认为表格可以从商店采购模型(y / n?)获取数据。如果是真的,我有一个问题:如何添加现有的表格进行建模? 因此,主要目标-通过服务器REST API将值从服务器获取到存在的选择域。

这是我现在拥有的: -代理商店:

Ext.define('Foresto.store.RESTstore',{ 
extend: 'Ext.data.Store',
storeID:'reststore',
proxy: {
    type:'rest',
    url:'http://localhost:6666/api/form',
    reader:{
        type: 'json',
        root: ''
    }
},
autoLoad: true});

-来自表单的一个:

Ext.define('Foresto.view.forms.Cutarea', {
extend: 'Ext.form.Panel',
title: 'ForestoL',
header: {
    cls: 'header-cls',

},
scrollable: true,
xtype: 'forestoL',

url: 'save-form.php',

items: [{
    xtype: 'selectfield',
    label: 'Field1',
    name: 'name'
},{
    xtype: 'selectfield',
    label: 'Field2',
    name: 'allotment'
}] ...

请帮助! 谢谢, 阿图尔。

1 个答案:

答案 0 :(得分:1)

请参阅this fiddle中的基本远程组合框。

{
    xtype: 'combo',
    fieldLabel: 'My Combo',
    valueField: 'id',
    displayField: 'title',
    anchor: '100%',
    store: new Ext.data.Store({
        autoLoad: true,
        fields: ['id', 'title'],
        proxy: {
            type: 'ajax',
            url: 'records.json'
        }
    })
}
相关问题