Reputation: 58742
I am exploring dojo grid, and could not find a good example of how to handle navigation by clicking on the row.
There is a simple grid example here
How to extend the code with the following requirement
any help would be a great time saver...
thanks.
EDIT: added javascript tag so that more user may see this post (only 9 so far with dojo alone)
Upvotes: 1
Views: 2189
Reputation: 730
I had to solve problems 1 and 2 above. You can use dojo.connect to connect the grid to the onRowClick event. For example, if you have a grid of the form:
<div dojoType="dojox.grid.DataGrid" jsId="grid" id="myGrid" structure="layout" selectionMode="single"></div>
You can then call in JavaScript:
dojo.connect(grid, "onRowClick", clickMethod);
clickMethod can then access the data from the row as follows:
function clickMethod(event) {
...
selected_index = grid.focus.rowIndex;
selected_item = grid.getItem(selectedIndex);
//Not sure if this is the most efficient way but it worked for me
selected_id = grid.store.getValue(selectedItem, "field_name_from_store");
...
}
I imagine you can do a location.href or similar after that.
Upvotes: 2