If double click for editing is too much, an option called "singleClickEdit" can be added so
that only a single click will be needed to edit the cell. This should be added to the <table> tag.
Selecting items
A check-box or radio button can be added in the left column to show selection. Defining the
structure as:
structure: [
{
type: "dojox.grid._CheckBoxSelector"
},
{
cells: [
{ name: "BPD Name", field: "bpdName", width: "90px" },
{ name: "Instance ID", field: "instanceId", width: "90px" },
{ name: "Task Status", field: "taskStatus", width: "90px" }
]
}
],
The selected items in the grid can be obtained by calling:
grid.selection.getSelected()
This will return an array of items.
It appears that grid.selection is a dojox.grid.DataSelection object. This object
has a property called selectedIndex which is the 0 based row of data. The code to get the
selected data is:
var x = grid.getItem(grid.selection.selectedIndex);
See also:
• Sitepen – Working with the Grid – 1.7
Adding new rows
The Data store associated with the Data Grid is "live". This means changes to the Data Store are
reflected in the Data Grid. Adding a new Item in the Data Store results in a new row being shown
in the table. To add a new row, we can perform work such as:
var grid = dijit.byId("gridId");
var store = grid.store;
store.newItem({a:"new a", b: "new B"})
Removing rows
Rows can also be removed from the Data Grid by updating the store. A convenience function
called removeSelectedRows() will remove selected rows from the table.
Replacing the data
The data in a data grid can be replaced by calling the grid's setStore() method which takes a
Page 177
Kommentare zu diesen Handbüchern