【问题标题】:How to make EXT JS model and proxy store work? (please_help!)如何使 EXT JS 模型和代理商店工作? (请帮忙!)
【发布时间】:2018-10-25 08:46:13
【问题描述】:

我还没有理解如何使用 REST api 链接服务器数据和表单的字段。

我有一些选择字段的表单。我对服务器上的这个特别字段有值。我认为表单可以从存储模型中获取数据(是/否?)。如果这是真的,我有一个问题:如何将现有表单添加到模型中? 所以主要目标 - 将值从服务器获取到现有表单的现有选择字段通过 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'
}] ...

请帮忙! 谢谢, 阿图尔。

【问题讨论】:

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


    【解决方案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'
            }
        })
    }
    

    【讨论】:

    • 所以不需要创建模型?我可以只为每个字段集成商店吗?
    • 这取决于用例,如果您的商店共享相同的模型,那么集中化会更好。
    猜你喜欢
    • 1970-01-01
    • 2013-12-22
    • 1970-01-01
    • 2014-02-03
    • 2013-09-23
    • 1970-01-01
    • 2018-09-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多