Select to view content in your preferred language

cannot select dgrid row when feature on map is selected

1199
4
Jump to solution
11-08-2012 09:53 AM
DerekMiller
Deactivated User
Hello all,

I'm currently working on an application that contains a feature layer (points) linked to a dgrid. I'm running into problems selecting the appropriate row in the dgrid when a feature on the map is selected.

I've defined a global variable that contains the unique feature name as a proxy for an id. This variable is overwritten each time the feature layer selection changes, by either clicking on a new feature or by scrolling through records in the popup. This much is functioning properly (writing the feature name to the console to verify).

I am hoping that I can select the appropriate row in the grid based on this variable as opposed to re-querying the feature layer.

I'm currently receiving a 'non_object_property_call' to the error console as a result of the _Row element being null, even though I am able to write the _Row object to the console and determine that the _Row id matches the feature name variable.

Code for my select grid function is this:
function selectGrid() {     console.log("selecting grid");     console.log(featureName);     var row = grid.row(featureName);     console.log(row);     rowID = row.id;     console.log(rowID);     if (row.id === featureName) {       console.log("derek sucks");       //selectRow(row);       grid.row(featureName).element.scrollIntoView();     } }


Also note that I'm using a dgrid/Grid as opposed to dgrid/onDemandGrid.

Any thoughts?

- d
0 Kudos
1 Solution

Accepted Solutions
DerekMiller
Deactivated User


Application currently sits here: www.portlandbps.com/gis/gda/index.html

It's buggy, particularly the 'zoom to feature and open popup when row in the grid is selected' feature I'm attempting to implement, but it's early.

Thanks.

- d


This has been resolved as well.

- d

View solution in original post

0 Kudos
4 Replies
DerekMiller
Deactivated User
Hello again everyone,

Now I'm truly confused. I've boiled down the code above in an attempt to select the relevant row and scroll the selected row into view when a feature on the map is clicked (I'll worry about styling the selected row once I can get this to work). The function is selecting the relevant row (using the .isSelected() method to write to the console for verification), but not scrolling. I'm now receiving an 'undefined method' error on scrollIntoView();. This is interesting, since the sample here uses this method.

Here is my code, the featureName variable is described in the previous post:

function selectGrid(e) {
    var row = window.grid.row(featureName);
    rowID = row.id;
    if (rowID === featureName) {
      window.grid.select(row);
      console.log(grid.isSelected(row));
      window.grid.scrollIntoView(row);
    }
  }


I really appreciate any input into this matter.

Thanks,

- d
0 Kudos
JohnGravois
Deactivated User
can you explain the reason for your hesitance to avoid querying the client side features?
0 Kudos
DerekMiller
Deactivated User
Simply because it seems duplicative. I don't see the need to re-query the client-side features. They are already being queried on a map click, and the ID from the selected feature is being assigned to a global var being passed to the select grid function. It's probably not the best way to do it (and I would being interested in improving my code if you have any suggestions), but I was able to come up with a work-around:

function selectGrid(e) {
    for (var i = 0; i < 250; i++) {
      grid.clearSelection();
      row = grid.row(i);
      console.log(row.data);
      if (row.data.id === featureID) {
        grid.select(i);
        row.element.scrollIntoView();
        break;
      }
    };
  }


Application currently sits here: www.portlandbps.com/gis/gda/index.html

It's buggy, particularly the 'zoom to feature and open popup when row in the grid is selected' feature I'm attempting to implement, but it's early.

Thanks.

- d
0 Kudos
DerekMiller
Deactivated User


Application currently sits here: www.portlandbps.com/gis/gda/index.html

It's buggy, particularly the 'zoom to feature and open popup when row in the grid is selected' feature I'm attempting to implement, but it's early.

Thanks.

- d


This has been resolved as well.

- d
0 Kudos