I have a suggestion that would simplify the way to retrieve specific cell values from data items when selecting multiple rows from a grid.
Right now, the only clean way to get cell values from selected rows would be to get the selected elements with grid.select(), then go through all the rows and then build your own array with the desired cell values.
Why not implement something like this:
var usernames_and_emails = grid.dataItems(grid.select(), ["username", "email"]);
The usernames_and_emails variable would contain all the selected rows as javascript objects, each object having the username and email properties.
If the second parameter is omitted for the .dataItems() method, then it should get all the columns for the grid.
Also, it would be nice to have a method to get a single column instead of an array of objects
for example
var user_ids = grid.dataItemsColumn(grid.select(), "id");
user_ids would be an array with ids.
I think this way it would be a bit easier to fetch data when working with multiple rows.
---------------------
Long story short
dataItems (tr_array [, fields_array])
returns an array of data items for the specified tr elements in the "tr_array"
if the "fields_array" is specified, only the fields specified in the array are returned
dataItemsColumn(tr_array, field_name);
returns an array of cell values (indicated by "field_name") for the specified tr elements in the "tr_array"
I guess this would eliminate the use of writing some repetitive code or implementing a custom function.
Gabriel.
Right now, the only clean way to get cell values from selected rows would be to get the selected elements with grid.select(), then go through all the rows and then build your own array with the desired cell values.
Why not implement something like this:
var usernames_and_emails = grid.dataItems(grid.select(), ["username", "email"]);
The usernames_and_emails variable would contain all the selected rows as javascript objects, each object having the username and email properties.
If the second parameter is omitted for the .dataItems() method, then it should get all the columns for the grid.
Also, it would be nice to have a method to get a single column instead of an array of objects
for example
var user_ids = grid.dataItemsColumn(grid.select(), "id");
user_ids would be an array with ids.
I think this way it would be a bit easier to fetch data when working with multiple rows.
---------------------
Long story short
dataItems (tr_array [, fields_array])
returns an array of data items for the specified tr elements in the "tr_array"
if the "fields_array" is specified, only the fields specified in the array are returned
dataItemsColumn(tr_array, field_name);
returns an array of cell values (indicated by "field_name") for the specified tr elements in the "tr_array"
I guess this would eliminate the use of writing some repetitive code or implementing a custom function.
Gabriel.