简体   繁体   中英

Dojo - Leave/Dismiss FilteringSelect in DGrid on Enter

I have a site with a table build with Dojo/DGrid.

Some columns of the grid use editor: dijit/form/FilteringSelect as editor, which works perfect. 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:

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. 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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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