Select to view content in your preferred language

Dojo Grid Selection

742
3
Jump to solution
11-24-2014 10:04 AM
WesAskew
Deactivated User

I have a Dojo grid that zooms to a selected point on the map when an ObjectId cell in the grid is clicked on.  I would like to change this to allow the zoom when the entire row or another attribute such as "Name" is clicked on.  The problem is that the ObjectId is my only unique identifier and I am getting no results when modifying and clicking on another field.  I have attached a text file that shows the code that I used to generate the grid and also the function that does the querying.  Could someone please provide some guidance on what I am missing?  Any help is greatly appreciated.  Thanks in advance.

0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

You're using the line

grid.on(".field-OBJECTID:click", selectSite);

in your application.

In my application, I'm using the following code to highlight a graphic when the user clicks on a row.

diveGrid.on(".dgrid-row:click", function (evt) {
    var selectedGrid = registry.byId("diveGrid");
    var row = selectedGrid.row(evt);
    var graphic = returnGraphicFromLayer(row.data.OBJECTID, myGraphicsLayer);
    if (graphic !== null) {
        flashFeature(graphic);
    }
});

function returnGraphicFromLayer(featureID, layerGraphic) {
    for (var i = 0; i < layerGraphic.graphics.length; i++) {
        if (layerGraphic.graphics.attributes.OBJECTID === featureID) { return layerGraphic.graphics; }
    }
    return null;
}

View solution in original post

3 Replies
KenBuja
MVP Esteemed Contributor

You're using the line

grid.on(".field-OBJECTID:click", selectSite);

in your application.

In my application, I'm using the following code to highlight a graphic when the user clicks on a row.

diveGrid.on(".dgrid-row:click", function (evt) {
    var selectedGrid = registry.byId("diveGrid");
    var row = selectedGrid.row(evt);
    var graphic = returnGraphicFromLayer(row.data.OBJECTID, myGraphicsLayer);
    if (graphic !== null) {
        flashFeature(graphic);
    }
});

function returnGraphicFromLayer(featureID, layerGraphic) {
    for (var i = 0; i < layerGraphic.graphics.length; i++) {
        if (layerGraphic.graphics.attributes.OBJECTID === featureID) { return layerGraphic.graphics; }
    }
    return null;
}
WesAskew
Deactivated User

Thanks, works great.  Out of curiosity, what does your myGraphicsLayer variable refer to?  Is it a subset of your layerGraphic feature layer?

0 Kudos
KenBuja
MVP Esteemed Contributor

That's the graphics layer itself.

var myGraphicsLayer= new GraphicsLayer({
    id: "featureGraphics",
    opacity: 0.5
});
0 Kudos