Login Register

When defining an onRowClick on the Grid, row selection breaks

I have defined an onRowClick on my grid, like so:

<div id="grid2" dojoType="dojox.Grid" elasticView="1" model="dataModel2" structure="layoutFileData" onRowClick="setUpDragging"></div>

When i do this, i can no longer select any rows in the grid. Usually, they would highlight by turning blue, but no longer.

Try dojo.connect

Try doing this...

dojo.connect(dojo.byId("grid2"), "onRowClick", setUpDragging);

Dru

Thanks for the suggestion.

Thanks for the suggestion. I tried that, but unfortunatley it did not work. Row selection now works, but my event is not firing, and when row selection was broke, it was.

I also tried to hook up events like in the test_events.html test page. It looked like this:

grid["onRowClick"] = function(e) {...}.

This approach had the exact same result as when declaring the event with markup. Row selection did not work, but the event fired.

Another try...

Hmm. I had exactly the same problem as you, but the dojo.connect() solved it for me. The basic problem is that you still need the default handler to be invoked since that's what handles changing the background color. Another way to accomplish the same thing would be with this code...

grid.onRowClick= function(event) {

  // your code goes here...

  this.default("onRowClick", arguments);
}

I have gotten it working by

I have gotten it working by combining parts of what you have posted. Here is the final result, and it is working...

var grid = dijit.byId("grid2");
dojo.connect(grid, "onRowClick", function(event) {

setUpDragging();

});

Thank you for your help!

Another way to get grid row to highlight with custom onRowClick

I am pretty new to dojo and am not sure if anything is in place to handle overloading/inheritence etc., so there may be an easier/more elegant way than this, but if you don't want to programmatically create your grid as in the solution above try this 'dirty' solution:

After your custom onRowClick does its own thing just call the same 2 methods that are in the grids default onRowClick () as this will give you the default behavior, which must include the highlighting of rows. (you can find the default in dojox/grid/_grid/publicEvents.js)

the HTML

<div id="grid2" dojoType="dojox.Grid" elasticView="1" model="dataModel2" structure="layoutFileData" onRowClick="setUpDragging"></div>

the code

function setUpDragging(e)       {
    // your code here.

    this.edit.rowClick(e);   // <- from default onRowClick method
    this.selection.clickSelectEvent(e)// <- from default onRowClick method
}

Great, it works!

Great, it works!