Javascript 编辑器网格中的自定义类型存储字段映射不正确

Javascript 编辑器网格中的自定义类型存储字段映射不正确,javascript,extjs,extjs4,extjs3,Javascript,Extjs,Extjs4,Extjs3,我有一个编辑器网格和一个自定义类型的存储 商店: var sourceStore = new Ext.data.JsonStore({ url: hp, storeId: 'labels-data-store', idProperty: 'ID', root: 'results', fields: [{ name: 'ID', type: 'int' }, { name: 'LanguageID',

我有一个编辑器网格和一个自定义类型的存储

商店:

var sourceStore = new Ext.data.JsonStore({
    url: hp,
    storeId: 'labels-data-store',
    idProperty: 'ID',
    root: 'results',
    fields: [{
        name: 'ID',
        type: 'int'
    }, {
        name: 'LanguageID',
        type: 'int'
    }, {
        name: 'KeyID',
        type: 'int'
    }, {
        name: 'Value',
        type: 'string'
    }, {
        name: 'ToolTip',
        type: 'string'
    }, {
        name: 'LanguageName',
        type: 'string'
    }, {
        name: 'KeyInfo',
        type: 'LanguageKeyInfo'
    },
    CUSTOM TYPE HERE !! !{
        name: 'ServerComments',
        type: 'string'
    }]
});
编辑器网格:

var sourceGrid = new Ext.grid.EditorGridPanel({
    id: 'source-grid',
    region: 'center',
    title: localize.sourceView,
    iconCls: 'source-view-title',
    store: sourceStore,
    trackMouseOver: true,
    disableSelection: false,
    loadMask: true,
    split: true,
    stripeRows: true,
    border: true,
    autoExpandColumn: 'label',
    cm: sourceColModel,

    // customize view config
    viewConfig: {
        forceFit: true,
        enableRowBody: true,
        showPreview: false,
        emptyText: localize.noRecordsFound
    },

    sm: new Ext.grid.RowSelectionModel({
        singleSelect: false,
        moveEditorOnEnter: true
    })
});
自定义类型实现:

LanguageKeyInfo = function () {
    this.ID = arguments[0];
    this.Value = arguments[1];
    this.Description = arguments[2];
}

Ext.data.Types.LANGUAGEKEYINFO = {
    convert: function (v, data) {

        if (!data) {
            return null;
        }

        if (!data.KeyInfo) {
            return null;
        }

        return new LanguageKeyInfo(
        data.KeyInfo.ID,
        data.KeyInfo.Value,
        data.KeyInfo.Description);
    },

    sortType: function (key) {
        return key.ID;
    },

    type: 'LanguageKeyInfo'
}
源列模型:

var sourceColModel = new Ext.grid.ColumnModel({
    columns: [{
        header: 'ID',
        dataIndex: 'ID',
        width: 50,
        hidden: true,
        sortable: true
    }, {
        header: 'Language ID',
        dataIndex: 'LanguageID',
        width: 50,
        hidden: true,
        sortable: true
    }, {
        header: 'Language',
        dataIndex: 'LanguageName',
        width: 20,
        hidden: true,
        sortable: true
    }, {
        header: 'Key ID',
        dataIndex: 'KeyID',
        width: 30,
        hidden: true,
        sortable: true
    }, {
        header: 'Key',
        dataIndex: 'KeyValue',
        width: 40,
        sortable: true,
        editor: new Ext.form.TextField({
            allowBlank: false,
            maxLength: 200
        })
    }, {
        header: 'Label',
        dataIndex: 'Value',
        sortable: true,
        editor: new Ext.form.TextField({
            allowBlank: false,
            maxLength: 500
        }),
        renderer: function (sc) {
            var lanID = getSelectedLanguageID() ? getSelectedLanguageID() : 1;
            switch (parseInt(lanID)) {
                case 2:
                    return '<div class="rtl">' + sc + '</div>';
                default:
                    return sc;
            }
        }
    }, {
        header: 'Description',
        dataIndex: 'KeyDescription',
        width: 30,
        editor: new Ext.form.TextField({
            allowBlank: true,
            vtype: 'englishOnly',
            maxLength: 100
        })
    }, {
        header: 'Tool Tip',
        dataIndex: 'ToolTip',
        width: 80,
        sortable: true,
        editor: new Ext.form.TextField({
            allowBlank: true,
            maxLength: 200
        })
    }]
});
var sourceColModel=new Ext.grid.ColumnModel({
栏目:[{
标题:“ID”,
数据索引:“ID”,
宽度:50,
隐藏:是的,
可排序:正确
}, {
标题:“语言ID”,
dataIndex:'LanguageID',
宽度:50,
隐藏:是的,
可排序:正确
}, {
标题:“语言”,
dataIndex:'LanguageName',
宽度:20,
隐藏:是的,
可排序:正确
}, {
标题:“密钥ID”,
dataIndex:'KeyID',
宽度:30,
隐藏:是的,
可排序:正确
}, {
标题:“键”,
dataIndex:'KeyValue',
宽度:40,
可排序:是的,
编辑器:新建Ext.form.TextField({
allowBlank:false,
最大长度:200
})
}, {
标题:“标签”,
dataIndex:'值',
可排序:是的,
编辑器:新建Ext.form.TextField({
allowBlank:false,
最大长度:500
}),
渲染器:函数(sc){
var lanID=getSelectedLanguageID()?getSelectedLanguageID():1;
开关(parseInt(lanID)){
案例2:
返回“+sc+”;
违约:
返回sc;
}
}
}, {
标题:“说明”,
dataIndex:'KeyDescription',
宽度:30,
编辑器:新建Ext.form.TextField({
allowBlank:是的,
vtype:'英语',
最大长度:100
})
}, {
标题:“工具提示”,
dataIndex:“工具提示”,
宽度:80,
可排序:是的,
编辑器:新建Ext.form.TextField({
allowBlank:是的,
最大长度:200
})
}]
});
当我开始编辑第一列行时,文本字段值为[object,object],这意味着网格正在将KeyInfo对象传递给textbox值


如何将其中一个KeyInfo属性发送到文本框并将其映射到存储记录???

对于初学者,您的dataIndex没有引用有效的记录映射:
dataIndex:'KeyValue',
可能应该是
dataIndex:'KeyInfo',

其次,我认为网格编辑器不支持自定义类型。当然,我可能错了。

首先,您的数据索引没有引用有效的记录映射:
dataIndex:'KeyValue',
可能应该是
dataIndex:'KeyInfo',

其次,我认为网格编辑器不支持自定义类型。当然,我可能错了。

您能为自定义类型字段显示列模型定义吗?您能为自定义类型字段显示列模型定义吗?关于数据索引,您是对的。我没有找到任何关于网格支持自定义类型的信息。如果你能在这个问题上遮住一些光线就好了。谢谢你的重播。关于数据索引你是对的。我没有找到任何关于网格支持自定义类型的信息。如果你能在这个问题上遮住一些光线就好了。谢谢你的重播。