dojogriddojox.grid.datagrid

Row Selection in Enhanced Grid


I am new to Dojo and i came across a problem that has me completely stumped. I am creating a data grid in Dojo with the Enhanced Grid .

Each row in the grid has a checkbox with which the row can be selected. The checkbox has been implemented using the indirectselection plugin.

Now when i select a row using the checkbox everything works fine. But when I select a row by clicking on other data cells the row does'nt get selected !

Heres the JSP part of the datagrid

<table  data-dojo-id="grid" data-dojo-type="dojox.grid.EnhancedGrid" plugins="{indirectSelection: {headerSelector:true}, filter: true,pagination: true}"
    data-dojo-props="store:icGrid, 
     clientSort:true "  formatterScope="myFormatters" 
    style="width: 100%; height: 20em;">
     <thead>
         <tr>
      <th width="25%" field="empNo"  formatter="formatLink">empNo</th>
      <th width="25%" field="name">name</th>
      <th width="25%" field="email">email</th>
      <th width="25%" field="phone">phone</th>
    </tr>
  </thead>
</table>

If I remove the code referring to indirect selection (plugins="{indirectselection...) the rows get selected when I click on other data cells (as they should). But I also need the checkbox that the indirectselection implements.

Is there a way to make the indirectselection work without taking away the row select functionality ?

Take a look at the grid in the page I will link below. I need a grid that works like that (The last grid in the page with the checkboxes)

http://dojotoolkit.org/documentation/tutorials/1.8/working_grid/demo/selector.php


Solution

  • I managed to resolve the issue by 1. using the cellClick event to listen 2. Get the rowindex of the cell when it is clicked 3. set it to selected.

    grid.on("CellClick", function(event)
        { 
            var rowId = event.rowIndex;
            grid.selection.setSelected(rowId, true);
            grid.render();
              }
    

    grid.selection.getSelected(); did not return the selected rows and I am wondering if this is a compatibility issue ? It seems like when i use the indirectSelection plugin the row Select is behaving in unexpected ways.