javascript - dojox.enhancedGrid 插件 IndirectSelection 中的 dojo.connect

标签 javascript events dojo grid

我偶然发现了一个奇怪的情况。

我们使用 dojo AMD 版本。 1.9.其中dojo.connect被dojo.on取代

到目前为止一切都还好。现在我想将事件监听器(选中复选框)连接到我的EnhancedGrid 的IndirectSelection 插件。我用 dojo.on 搜索解决方案,但只找到 dojo.connect?!

这是正确的吗?我的意思是 dojo.connect 在 dojo 1.9 中一般已被弃用?

这是我在道场端找到的代码:

dojo.connect(grid.selection, 'onSelected'|'onDeselected', function(rowIndex){...})

引用:http://dojotoolkit.org/reference-guide/1.9/dojox/grid/EnhancedGrid/plugins/IndirectSelection.html#usages

这是我的代码:

if(!registry.byId("GraphGrid")){
        grid = new EnhancedGrid({
                    id: 'GraphGrid',
                    store: GraphicStore,
                    query: { ident: "*" },
                    structure: layout,
                    rowSelector: '20px',
                    keepSelection: false,
                    plugins: {
                        indirectSelection: {
                        headerSelector:false, 
                        width:"40px", 
                        styles:"text-align: center;"
                        }}                          
                    },"GridGraphicInMap");

                /*Call startup() to render the grid*/
                grid.startup();

                grid.on("rowClick", function(evt){
                    var idx = evt.rowIndex,
                        item = this.getItem(idx);
                    //  get a value out of the item
                    var value = this.store.getValue(item, "geom");
                    highlightGeometry(value,true);
                });

                dojo.connect(grid.selection, 'onSelected', getSelectedItems);

                }
                else {
                    setTimeout(function(){
                    grid.setStore(GraphicStore);
                    }, 1000);
                }...

我尝试将其更改为 dojo.on 或 grid.selection.on('Selected',getSelectedItems);但它不起作用。在这种特殊情况下,dojo.connect 仍然是正确的连接方式吗?

上面的代码工作正常,没有任何问题。

问候,米里亚姆

最佳答案

您可以使用dojo.connect,它不会影响事件触发。 并尝试按以下方式使用连接:

 dojo.connect(grid, 'onSelected', getSelectedItems);

或者 dojo.connect(grid, 'onselectionchanged', getSelectedItems);

如果其中任何一个不起作用,请告诉我。

关于javascript - dojox.enhancedGrid 插件 IndirectSelection 中的 dojo.connect,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19515935/

相关文章:

jQuery 更改事件未针对输入字段触发

javascript - Dojo/Dijit 设置无效消息和验证失败

Dojo 1.7.2 拖放错误 - "mouseButtons.isLeft"

javascript - 如何访问 Google Apps For Your Domain 电子表格的 JSONP 提要?

javascript - 原型(prototype)方法未被调用

javascript - Bootstrap 轮播幻灯片 2 中的第二个 Google 图表未显示

javascript - Dojo 风格编码

javascript - 将JS单行对象实例化转换为 block 实例化

python - 文件更改事件网络共享

python - 检查窗口是否在后台 Tkinter