multiple select from Dojo grid

4636
20
Jump to solution
01-28-2014 11:44 PM
ShaneCarey
New Contributor
Hey,

Has anybody used this example:

http://blogs.esri.com/esri/arcgis/2009/12/03/display-attributes-in-a-dojox-datagrid/

except changing the selectionMode to multiple

I have tried changing it but it will not work. I simple changed lines:

        <table dojotype="dojox.grid.DataGrid" jsid="grid" id="grid"
              selectionMode="none">

to

        <table dojotype="dojox.grid.DataGrid" jsid="grid" id="grid"
              selectionMode="multiple">

But nothing changes. Any row I click on the table, I need to highlight on the map.

Thanks
0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor
This works properly. I added the Color module so the line looks like this

fl.setSelectionSymbol(new SimpleLineSymbol(SimpleLineSymbol.STYLE_DASH, new Color([255, 0, 0]), 3));

View solution in original post

0 Kudos
20 Replies
KenBuja
MVP Esteemed Contributor
Have you thought of using dGrid instead? There's an example on how to use it, but the sample doesn't do anything with multiple selections (like highlighting multiple states). You'd have to changed the coding to deal with multiple selections.

As for DataGrid, have you tried leaving off the selectionMode property, since the default is "extended"? Have you also tried adding programmatically like the examples here?
0 Kudos
ShaneCarey
New Contributor
Im very new to javascript so Im trying to take an example and modify it slightly to suit my needs. That example you provided me with would work but Im not sure how to modify it to select multiple polygons. I dont need it to zoom to the polygon.

Thanks
0 Kudos
KenBuja
MVP Esteemed Contributor
Here's a modification of the dGrid example to just highlight the selected states. You can select multiple records in the grid using the mouse + Ctrl key.

                function selectState(e) {
                    // select the feature
                    var fl = map.getLayer("states");
                    var query = new Query();
                    //query.objectIds = [parseInt(e.target.innerHTML)];
                    var selection = [];
                    var selected = window.grid.selection;
                    if (selected) {
                        for (row in selected) {
                            selection.push(parseInt(row));
                        }
                    }
                    query.objectIds = selection;
                    fl.selectFeatures(query, FeatureLayer.SELECTION_NEW, function (result) {
                        if (result.length) {
                            // re-center the map to the selected feature
                            //window.map.centerAt(result[0].geometry.getExtent().getCenter());
                        } else {
                            console.log("Feature Layer query returned no features... ", result);
                        }
                    });
                }
0 Kudos
ShaneCarey
New Contributor
This is great,

Thanks you so much. I need to implement this with a polyline rather than polygon. I presume this will work with Polyline?

Thanks again. Starbar!!
0 Kudos
KenBuja
MVP Esteemed Contributor
Yes it will. You'll have to make a change to this line

fl.setSelectionSymbol(new SimpleFillSymbol().setOutline(null).setColor("#AEC7E3"));


to use a SimpleLineSymbol. Otherwise you'll get something like this:

[ATTACH=CONFIG]30938[/ATTACH]
0 Kudos
ShaneCarey
New Contributor
Great thanks, I have it working, just cant get it to highlight.

I changed that line of code to this:

fl.setSelectionSymbol(new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_DASH, new dojo.Color("blue"));

And I also changed:
From
"esri/symbols/SimpleFillSymbol",

to

"esri/symbols/SimpleLineSymbol",

Any ideas, your help is really appreciated btw
0 Kudos
KenBuja
MVP Esteemed Contributor
This works properly. I added the Color module so the line looks like this

fl.setSelectionSymbol(new SimpleLineSymbol(SimpleLineSymbol.STYLE_DASH, new Color([255, 0, 0]), 3));
0 Kudos
ShaneCarey
New Contributor
Your a Star.

Thanks very much,

what editor do you use for debugging by the way?

Thanks
0 Kudos
ShaneCarey
New Contributor
Hey,

I still cant get it too work and it seems to be the following lines of code that is stopping it:

                var fl = new FeatureLayer(window.statesUrl, {
                    id: "states",
                    mode: 1, // ONDEMAND, could also use FeatureLayer.MODE_ONDEMAND
                    outFields: window.outFields


What does this "states" field do. I have only one layer in my service and I think this is what is causing the problem.

Thanks
0 Kudos