0

我目前正在使用带有分页、过滤和单元格编辑的 Dojo EnhancedGrid。

问题是在一个页面中,我需要在编辑单元格时更新另一个值。当我更新这个值时,我失去了选择的单元格,所以我需要单击下一个单元格来选择它并修改它。无法执行 Enter / edit / enter / down / enter / edit(Excel 类似版本)。

这是我的代码的一部分:

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

我也使用增强的道场网格,在那里我遇到了类似的问题。我用它来重新加载数据:

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

有了这个,你总是应该得到你操纵的最后一行,最终也是最后一个选择的......。

于 2013-02-01T07:11:19.010 回答
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 回答