dojox.enhancedGrid插件中的dojo.connect IndirectSelection

时间:2013-10-22 10:57:10

标签: javascript events dojo grid

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

我们使用道场AMD Vers。 1.9。其中dojo.connect被dojo.on替换为

到目前为止一切都还可以。现在我想将Eventlistener(选中复选框)连接到我的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仍然是正确的连接方式吗?

上面的代码运行正常,没有任何问题。

此致,Miriam

1 个答案:

答案 0 :(得分:0)

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

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

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

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

相关问题