I've been looking into dgrid and I'm trying to figure out if there's a way to attach an event to a grid that uses dojo/on without explicitly calling grid.on but, instead, passes it as a method (or set of methods) in the initial configuration of the grid. The reason for this is because the grid instance itself out of scope upon creation and I can't find any documentation on it.

So, instead of

var grid = new (declare[Grid])({}, element);
grid.on('.dgrid-row:click', function(){console.log('Hello World!')});

having something like

var grid = new (declare[Grid])({
    'events' : {
        '.dgrid-row:click' : function(){console.log('Hello World!')}
    }
}, element);

Ideas? Alternatives?

有帮助吗?

解决方案

You can use the the DijitRegistry extension, which will allow you to get a reference to your grid like you would with a normal dijit widget, through registry.byId... then you can use grid.on, as usual.

Example : https://github.com/SitePen/dgrid/wiki/DijitRegistry

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top