Skip to Content | Skip to Navigation

Working with selections

To get the current selected rows of the grid, you can use the method yourGrid.selection.getSelected(). You will get an array of the selected items. The following code shows an example:

<script type="text/javascript">
<span dojoType=""
    jsId="store2" url="/_static/dojo/dojox/grid/tests/support/movies.csv">
    Select a single row or multiple rows in the Grid (click on the Selector on the left side of each row).
    After that, a click on the Button "get all Selected Items" will show you each attribute/value of the
    selected rows.
<table dojoType="dojox.grid.DataGrid"
    query="{ Title: '*' }"
    style="width: 400px; height: 200px;"
            <th width="300px" field="Title">Title of Movie</th>
            <th width="50px">Year</th>
            <th colspan="2">Producer</th>
<div dojoType="dijit.form.Button">
    get all Selected Items
    <script type="dojo/method" event="onClick" args="evt">
        // Get all selected items from the Grid:
        var items = grid2.selection.getSelected();
            // Iterate through the list of selected items.
            // The current item is available in the variable
            // "selectedItem" within the following function:
            dojo.forEach(items, function(selectedItem) {
                if(selectedItem !== null) {
                    // Iterate through the list of attributes of each item.
                    // The current attribute is available in the variable
                    // "attribute" within the following function:
                    dojo.forEach(, function(attribute) {
                        // Get the value of the current attribute:
                        var value =, attribute);
                        // Now, you can do something with this attribute/value pair.
                        // Our short example shows the attribute together
                        // with the value in an alert box, but we are sure, that
                        // you'll find a more ambitious usage in your own code:
                        alert('attribute: ' + attribute + ', value: ' + value);
                    }); // end forEach
                } // end if
            }); // end forEach
        } // end if
<style type="text/css">
    @import "/_static/dojo/dojox/grid/resources/Grid.css";
    @import "/_static/dojo/dojox/grid/resources/nihiloGrid.css";
    .dojoxGrid table {
        margin: 0;

Grid 1.2 supports a new parameter “selectionMode” which allows you to control the behaviour of the selection functionality:

deactivates the selection functionality
let the user select only one item at the same time
let the user selects more than one item at the same time
‘extended’ (default)
not sure, what’s the difference between “multiple” and “extended”