Click here to Skip to main content
15,885,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Using the code at http://dojotoolkit.org/reference-guide/1.8/dojox/grid/DataGrid.html#working-with-selections[^], I coded to populate the results into the grid (see the related code below).
HTML
<table dojotype="dojox.grid.DataGrid" id="grid" noDataMessage="No results found in the current map extent" 
    style="height:250px; overflow:scroll; font-size:smaller;" selectionMode="single" >
  <thead>
    <tr>
      <th field="OBJECTID" width=25px >Id</th>
      <th field="STATION_STOP_SITE" width=120px  >Location Site</th>
      <th field="INCIDENTFULLADDRESS"  width=170px    >Address</th>
    </tr>
  </thead>
</table>
...
dojo.require("dojo.store.Memory");
dojo.require("dgrid.Selection");
dojo.require("dojo.on");
dojo.require("dojo.dom");
dojo.require("dojo.domReady!");
dojo.require("dojo.parser");
....
function GetItemFromGrid(e) {
  var count = e.rowCount;       // return 115
  var items = grid.selection.getSelected();
  ...       }

However, grid.selection returns 'undefined'. I tried to get the row and then retrieve its values, but could not find why the selection dose not work. Great appreciate if you can help.
Posted
Comments
ZurdoDev 16-Dec-14 14:29pm    
Where is grid defined?
s yu 16-Dec-14 14:58pm    
See my posted code,
<table dojotype="dojox.grid.DataGrid" id="grid" ... >
Thanks.
ZurdoDev 16-Dec-14 15:06pm    
But "grid" in JavaScript means nothing (undefined) until you define it.

You need to set var grid = $("#grid") or something like that but it won't magically know what you are referring to.
s yu 16-Dec-14 15:16pm    
I tried this below:
var g = document.getElementById('grid');
but g.selection is still undefined. Any advisory? Thanks.
ZurdoDev 16-Dec-14 15:32pm    
.selection is not a built-in JavaScript method which means to call grid.selection, grid needs to be of some type. You should go back to wherever you found the code and see how it works.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900