简体   繁体   English

Dojo-在Enter上在DGrid中进行离开/关闭过滤选择

[英]Dojo - Leave/Dismiss FilteringSelect in DGrid on Enter

I have a site with a table build with Dojo/DGrid. 我有一个使用Dojo / DGrid构建表的站点。

Some columns of the grid use editor: dijit/form/FilteringSelect as editor, which works perfect. 网格的某些列使用editor: dijit/form/FilteringSelect作为编辑器,效果很好。 As the user hits the return key, the value is accepted and the editor closes. 当用户按下返回键时,该值被接受并且编辑器关闭。

Other columns of the same grid have a custom defined renderCell, because the unterdying store url differs in every row: 同一网格的其他列具有自定义定义的renderCell,因为在每一行中,存储URL的含义各不相同:

function myCustomRenderCell(object, item, node) {
    node.innerHTML = '<div class="myClass"></div>';
    var filteringSelect = new FilteringSelect({
        label: 'myLabel',
        name: 'myName',
        displayedValue: item.myValue,
        store: new DstoreAdapter (
            new RestMemoryStore ({
                idProperty: 'id',
                target: 'myUrlToJsonData',
            })
        ),
        onChange: function(newValue) {
            var rowData = filteringSelect.store.get(newValue);
            var gridCell = this.domNode.offsetParent;
            var dataCell = grid.cell(gridCell);
            rowData.then(function(row){
                var eventObject = {
                    grid: this,
                    cell: dataCell,
                    oldValue: "",
                    value: row.name,
                    bubbles: true,
                    cancelable: true
                };
                on.emit(dataCell.element, 'dgrid-datachange', eventObject);
                grid.updateDirty(dataCell.row.id, 'myLabel', row.name);
            });
        }
    }, node.children[0]);
    filteringSelect._destroyOnRemove = true;
    filteringSelect.startup();
}

Unlike the default FilteringSelect mentions in the beginning this one is not left as the use hits the return key. 与开始时提到的默认FilteringSelect不同,此用法在用户按回车键时就不会保留。 The value is processed correctly. 该值已正确处理。 But except of pressing tab which places the cursor inside the next custom editor or using the mouse there is no way to leave this editor. 但是除了按下将光标置于下一个自定义编辑器内的选项卡或使用鼠标外,没有任何方法可以离开此编辑器。

Any ideas how to set up this custom build FilteringSelect to dismiss on return like the default editor in the grid does? 有什么想法如何设置此自定义版本FilteringSelect以像网格中的默认编辑器一样在返回时关闭?

try out: add an event handler for key press: 试用:为按键添加事件处理程序:

onKeyPress: function(event){
    if (event.charOrCode == keys.ENTER) {
        filteringSelect.set("focused", false);
    }
}

Thanks to Manjunatha for the helpful hint. 感谢Manjunatha的有用提示。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM