Select to view content in your preferred language

Can you set multiple idProperty fields in Dojo Grid?

975
4
Jump to solution
08-01-2017 11:52 AM
MarioEstevez
New Contributor III

I'm using a Dojo Grid to display the features selected on a map. I wonder if it's possible to have more than one field as idProperty. The reason I need this is because I need to use one of the IDs to select the feature on the map when the row is clicked on the grid. And I need to other key value to pass it to a web service once the user selects multiple  records from the grid.

If having multiple IdProperty fields is not possible, then I need to know if I can get all the columns from a selected row.

Thanks in advance for your help.

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Mario,

  So you just get the selected row ids from the grid and use the row data method I have in my code to get the drawing id for each of the selected rows.

View solution in original post

4 Replies
RobertScheitlin__GISP
MVP Emeritus

Mario,

   Assigning multiple IdProperty fields is not the proper solution if it even is possible. You just use your click event :

grid.on(".field-id:click", someFunction);

// fires when a row in the dgrid is clicked
function someFunction(e) {
  var row = grid.row(e);
  console.info(row.data); // This has all the row data
MarioEstevez
New Contributor III

Robert,

Thanks so much for your prompt response. Perhaps I need to provide a bit more information about my problem. I have an attribute called Drawing # in my layers, which was supposed to be unique, but it turns out is not. For example, more than one line might have the same Drawing #. If I use ObjectID as IdProperty for the dgrid, I have no problem zooming in to a feature when that feature is clicked on the grid.
Now my application allows users to select multiple records from the grid. When that happens I need to pass all the Drawing #s selected by the user to a web service. My problem is that the grid.selection returns the IdProperty values of the selected rows. I can't seem to find a way to extract the Drawing #s from the selection unless the Drawing # is set as IdProperty. That's why I was thinking that if it was possible to have multiple IdProperty values, I could set the Drawing # to be one of those values.

Grid showing non-unique values.

Thanks!

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Mario,

  So you just get the selected row ids from the grid and use the row data method I have in my code to get the drawing id for each of the selected rows.

MarioEstevez
New Contributor III

Robert,

So, I went with something like this:

selection = [];

var selected = grid.selection;

       for (selRow in selected) {
            var gridRow = grid.row(selRow);
            selection.push(gridRow.data.CONSTRUCTION_DRAWING);
        }

Thanks so much for your help.