0

現在、ページネーション、フィルタリング、およびセル編集で Dojo EnhancedGrid を使用しています。

問題は、あるページで、セルが編集されたときに別の値を更新する必要があることです。この値を更新すると、選択したセルが失われるため、次のセルをクリックして選択して変更する必要があります。そのため、入力・編集・入力・下へ・入力・編集(エクセルライク版)はできません。

ここに私のコードの一部があります:

var store = new dojo.data.ItemFileWriteStore({'data':data});
var grid = new dojox.grid.EnhancedGrid({
    id: 'grid',
    store: store,
    structure: structure,
    columnReordering: true,
    autoHeight: true,
    autoWidth: true,
    initialWidth: '100%',
    escapeHTMLInData: false,
    plugins: {
            pagination: {
                pageSizes: ["10", "25", "50", "All"],
                description: true,
                sizeSwitch: true,
                pageStepper: true,
                gotoButton: true,
                maxPageStep: 4,
                position: "bottom"

            },
            filter : {}
    },
    onStartEdit: function(inCell, inRowIndex)
    {
        item = grid.selection.getSelected()[0];
        currentVal = item[inCell['field']][0];
    },
    doApplyCellEdit: function(inValue, inRowIndex, inAttrName) {
          if(inValue != currentVal){
               [...]
               $.ajax(url, data, {
                           success:function(data, textStatus) {
                                val = parseInt(data["info"]);
                                if(!isNaN(val)) {
                                    grid.store.setValue(item, 'info', val);
                                    grid.update();
                                } else {
                                    grid.store.setValue(item, 'info', 0);
                                    grid.update();
                                }
                            }
                });
            }

        }


    });
    dojo.byId("gridDiv").appendChild(grid.domNode);
    grid.startup();

これを処理する解決策はありますか?

4

2 に答える 2

0

多くの調査の結果、次の解決策が見つかりました。

           $.ajax(url, data, {
                       success:function(data, textStatus) {
                            val = parseInt(data["info"]);
                            if(!isNaN(val)) {
                                grid.store.setValue(item, 'info', val);
                                grid.update();
                                window.setTimeout(function() {
                                    grid.focus.next();
                                }, 10);
                            } else {
                                grid.store.setValue(item, 'info', 0);
                                grid.update();
                                window.setTimeout(function() {
                                    grid.focus.next();
                                }, 10);
                            }
                        }
            });

グリッドが更新される前に短い遅延があり、フォーカスが失われるため、タイマーが必要です。

于 2013-02-04T16:09:11.303 に答える
0

私も強化された Dojo グリッドを使用していますが、同様の問題がありました。これを使用して、データを正しくリロードしました。

require(["dijit/registry"],function(registry)   {
            var grid = registry.byId('grid');
            grid._lastScrollTop=grid.scrollTop;
            grid._refresh();
        });

これにより、操作した最後の行を常に取得し、最終的には最後に選択した行も取得する必要があります... .

于 2013-02-01T07:11:19.010 に答える