首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >数据存储具有空的数据属性

问数据存储具有空的数据属性
EN

Stack Overflow用户
提问于 2012-10-31 21:43:40
回答 1查看 175关注 0票数 0

我正在使用Ext.js,并试图设置一个数据存储,并将其映射到我的FormPanel上的数据字段,这样我就可以轻松地访问数据输入。

我的映射中缺少一些东西:当我在文本字段中输入数据并点击提交按钮的提交处理程序时,存储上的data属性为空。我希望它包含页面上的数据输入。有人能帮帮忙吗?非常感谢:

代码语言:javascript
复制
infoPanel = function () {
    this.store = new Ext.data.JsonStore({
        autoLoad: true,
        root: 'Data',
        storeId: 'creditMemoStore',
        fields: ['shipto', 'billto', 'reasonCode', 'creditClaimed', 'adjustmentAmount', 'poNumber']
    });


this.fieldset = {
    xtype: 'fieldset',
    flex: 1,
    border: false,
    defaultType: 'field',
    items: [
        {
            xtype: 'textfield',
            labelWidth: 160,
            fieldLabel: 'Ship to',
            name: 'shipto',
            //dropdown
            allowBlank: false
        },
        {
            xtype: 'textfield',
            labelWidth: 160,
            fieldLabel: 'Bill to',
            name: 'billto',
            //dropdown
            allowBlank: false
        },
        {
            xtype: 'textfield',
            labelWidth: 160,
            fieldLabel: 'Reason Code',
            name: 'reasonCode',
            //dropdown
            allowBlank: false
        },
        {
            labelWidth: 160,
            xtype: 'numberfield',
            allowNegative: false,
            fieldLabel: 'Amount',
            allowBlank: false,
            name: 'creditClaimed'
        },
        {
            labelWidth: 160,
            xtype: 'numberfield',
            allowNegative: false,
            fieldLabel: 'Adjustment Amount',
            name: 'adjustmentAmount',
            allowBlank: false,
            maxLength: 5
        },
        {
            xtype: 'textfield',
            labelWidth: 160,
            fieldLabel: 'Customer PO Number',
            allowBlank: false,
            name: 'poNumber',
            maxLength: 15
        },
        {
            xtype: 'textfield',
            labelWidth: 160,
            fieldLabel: 'Debit Memo Number',
            allowBlank: false,
            name: 'dmNumber',
            maxLength: 50
        },
        {
            xtype: 'textfield',
            labelWidth: 160,
            fieldLabel: 'Credit Memo Number',
            allowBlank: false,
            name: 'cmNumber',
            maxLength: 6
        },
        {
            xtype: 'textfield',
            labelWidth: 160,
            fieldLabel: 'Currency Code',
            name: 'currencyCode',
            //dropdown
            allowBlank: false,
            maxLength: 3,
            value: 'USD'
        }
    ]
};

this.panel = new Ext.form.FormPanel({
    renderTo: Ext.getBody(),
    width: 700,
    title: 'Create Credit Memo',
    height: 400,
    frame: true,
    id: 'creditMemoFormPanel',
    layout: 'vbox',
    layoutConfig: {
        align: 'stretch'
    },
    items: [
        this.fieldset
    ],
    store: this.store,
    buttons: [
        {
            text: 'Reset',
            handler: function () {
                this.up('form').getForm().reset();
            }
        },
        {
            text: 'Submit',
            formBind: true,
            handler: function () {
                var form = this.up('form').getForm();
                var store = Ext.StoreMgr.get('creditMemoStore');
                var dataObject = { testPost: store.data};
                if (form.isValid()) {
                    Ext.Ajax.request({
                        url: 'CreateCreditMemo',
                        jsonData: Ext.JSON.encode(dataObject),
                        success: function() { Ext.Msg.alert('json post Success'); },
                        failure: function () { Ext.Msg.alert('json post Fail'); },
                    });
                }
            }
        }
    ]
});

}

代码语言:javascript
复制
Ext.onReady(function () {
    var ip = new infoPanel();
});
EN

回答 1

Stack Overflow用户

发布于 2012-10-31 23:51:08

Ext.js存储仅用于一次显示多组数据的记录。

商店不适用于基本表单。Ext.js表单在提交时自动提交所有字段的值。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13159385

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档