【问题标题】:dojox.grid.enchancegrid delete row, rows deletet from server but not from griddojox.grid.enchancegrid 删除行,从服务器但不从网格中删除的行
【发布时间】:2012-10-03 07:46:38
【问题描述】:

我的 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
                }
            }

        });

【问题讨论】:

    标签: javascript datagrid dojo


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-06-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-30
      • 2011-11-03
      • 1970-01-01
      相关资源
      最近更新 更多