dojo.connect in dojox.enhancedGrid plugin Indirect

2019-07-29 12:58发布

I stumbled about a strange circumstance.

We use dojo AMD Vers. 1.9. in which dojo.connect is replaced by dojo.on

So far all is okay. Now i want to connect an Eventlistener ( Checkbox is Selected) to the IndirectSelection-plugin of my EnhancedGrid. I search for a solution with dojo.on but just find dojo.connect?!

Is that correct? I mean dojo.connect is deprecated generaly in dojo 1.9?

This is the code i find in the dojo-side:

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

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

and here's my Code:

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);
                }...

I tried to change it to dojo.on or grid.selection.on('Selected',getSelectedItems); but it doesn't work. Is in this special Case dojo.connect still the right way to connect?

The code above works fine, theres nothing wrong with it.

Regards, Miriam

1条回答
我命由我不由天
2楼-- · 2019-07-29 13:24

You can use dojo.connect it wont affect event triggering. And try using your connect in the following manner:

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

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

Please let me know if any of these doesn't work.

查看更多
登录 后发表回答