0

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?

sgcharlie
  • 1,006
  • 1
  • 10
  • 25
  • Can you expand on the problem you are trying to solve? I don't understand how the second example is functionally different than the first. – sixtyfootersdude Jun 24 '14 at 17:41
  • It's been so long since I looked at this question so I can't fully remember the context but I believe that, at the time, I was dealing with a library that allowed me to pass in configuration options and set up the grid for me but didn't return the grid object itself. You are right, though, the two are functionally equivalent. – sgcharlie Jun 25 '14 at 14:54

1 Answers1

0

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

Philippe
  • 6,703
  • 3
  • 30
  • 50