【问题标题】:How to create cell editor for speciall cell in grid with another grid and selection of value from it in ExtJs?如何使用另一个网格为网格中的特殊单元格创建单元格编辑器并在 ExtJs 中从中选择值?
【发布时间】:2015-02-20 07:27:17
【问题描述】:

我正在尝试使用网格创建编辑器,现在我有这样的变体:

var panelWithGrid = Ext.create('Ext.grid.Panel', {
    store: cellEditorGridStore,
    autoScroll: true,
    width: 300,
    height: 200,
    sortable: true,
    title: "My Editor",
    ...
    columns: [
        {
            dataIndex: "first",
            width: "13%",
            text: "First"
        },
        {
            dataIndex: "second",
            width: "87%",
            text: "Second"
        }
    ],
    bbar: [
        {
            xtype: "button",
            text: "change value of cell",
            handler: function(){
                //close action + inserting of selected value from one grid to another?
            }
        },
        {
            xtype: "button",
            text: "close editor",
            handler: function(){
                //normal close action? tried to hide, that works bad.
            }
        }
    ]
});
var myOwnCellEditor = Ext.create('Ext.grid.CellEditor', {
    autoCancel: true,
    closeAction: 'hide',
    field: panelWithGrid
});

此外,我在所有列之一中创建了另一个带有 getEditor 属性的网格

...
getEditor: function(record){
    if(record.raw.myColumnIndex==="gridEditor"){
        Ext.Ajax.request({
            ...
            async: false,
            success: function(response, options){
                ...//downloading of cellEditorGridStore
            }
    }
    return myOwnCellEditor;
}

所以我对这样的编辑器有很多问题。当我单击单元格进行编辑时,出现错误:

Uncaught TypeError: undefined is not a functionext-all.js:38 
Ext.define.startEditext-all.js:38 
Ext.define.showEditorext-all.js:38 
b

当我尝试隐藏编辑器时,第二次显示不正确。您知道实现此类编辑器的更好方法吗?

【问题讨论】:

    标签: javascript extjs extjs4.2 tablecelleditor


    【解决方案1】:

    我找到了另一种方法来创建小部件以从其他网格中获取价值。 我添加到我的网格中

    listeners: {
        cellclick: function(gridView,htmlElement,columnIndex,dataRecord){
            if(columnIndex == 1){
                if(dataRecord.data.second){
                    ...
                    //memorize current dataRecord to change value by using of
                    //dataRecord.set("second", new_value) and show my grid-editor
                }
            }
        })
    }
    

    这样的决定效果很好,但它不是编辑器。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多