Javascript dojox.grid.enchancegrid删除行,从服务器删除行,但不从网格删除行

Javascript dojox.grid.enchancegrid删除行,从服务器删除行,但不从网格删除行,javascript,datagrid,dojo,Javascript,Datagrid,Dojo,我的enchancegrid名为unitsGrid,运行正常。我可以添加行和删除行,但当我删除行时,我会遇到一些我无法解决的问题,因此行在删除时不会从我的unitsGrid中消失。我已经看了好几个小时的代码了,但我似乎弄不明白。 提前谢谢 dojo.connect(unitsGrid, "onRowClick", unitsGrid, function(evt, rowIndx, fieldIndx){ var idx = evt.rowIndex;

我的enchancegrid名为
unitsGrid
,运行正常。我可以添加行和删除行,但当我删除行时,我会遇到一些我无法解决的问题,因此行在删除时不会从我的unitsGrid中消失。我已经看了好几个小时的代码了,但我似乎弄不明白。 提前谢谢

dojo.connect(unitsGrid, "onRowClick", unitsGrid, function(evt, rowIndx, fieldIndx){

            var idx = evt.rowIndex;
            var item = this.getItem(idx);
            var id = unitsGrid.store.getValue(item, "id");

            if(evt.cellIndex == 3) {
                var con = confirm("Är du säker på att du vill radera denna transaktion?");
                if(con == true) {
                    dojo.xhrPost({
                        url: url,
                        content: {
                            id: id
                        },
                        handleAs: "text",
                        load: function(data) {
                            var selectedRows = grid.selection.getSelected();
                            if (selectedRows.length) {
                            // Iterate through the list of selected items.
                            // The current item is available in the variable
                            // "selectedItem" within the following function:
                                dojo.forEach(selectedRows, function(selectedItem) {
                                    if (selectedItem !== null) {
                                        // Delete the item from the data store:
                                        try {
                                            unitsGrid.store.deleteItem(selectedItem);
                                        }
                                        catch(error) {
                                            console.log("Returned error: " + error.message);
                                        }
                                    } // end if
                                }); // end forEach
                            } // end if
                            console.log("Return value: " + data);
                        },
                        error: function(error) {
                            console.log(error);
                        }
                    }); // end xhrPost
                }
            }

        });
只需调用dijit.byId('unitsGrid').removeSelectedRows()