dojo grid: naviagion

2.1k views Asked by At

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

  1. handle doubleclick event on row items
  2. read the identifier and extract the value corresponding to the selected row ( 12 for first row)
  3. redirect to {current domain}/view/{identifier} (like www.example.com/view/12)

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)

1

There are 1 answers

0
brokenbeatnik On

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.