Get selected item(s) in CRM grid
The following will retrieve an array containing the Id values of the selected records in the grid:
// get array of selected records
var a = document.all['crmGrid'].InnerGrid.SelectedRecords;
var selectedItems = new Array(a.length);
for (var i=0; i < a.length; i++)
{
selectedItems[i] = a[i][0];
}
alert(selectedItems);
//To get all of the records in the grid (ie. “All Records on Current Page”):
// array of all records on current page
var iTotal = document.all['crmGrid'].InnerGrid.NumberOfRecords;
var o = document.all['crmGrid'].InnerGrid;
var allItems = new Array;
var ii = 0;
for (var i=0; i < iTotal; i++)
{
allItems[ii] = o.rows[i].oid;
ii++;
}
alert(allItems);
Happy coding...
// get array of selected records
var a = document.all['crmGrid'].InnerGrid.SelectedRecords;
var selectedItems = new Array(a.length);
for (var i=0; i < a.length; i++)
{
selectedItems[i] = a[i][0];
}
alert(selectedItems);
//To get all of the records in the grid (ie. “All Records on Current Page”):
// array of all records on current page
var iTotal = document.all['crmGrid'].InnerGrid.NumberOfRecords;
var o = document.all['crmGrid'].InnerGrid;
var allItems = new Array;
var ii = 0;
for (var i=0; i < iTotal; i++)
{
allItems[ii] = o.rows[i].oid;
ii++;
}
alert(allItems);
Happy coding...
Labels: array, crm, crm 4.0, dynamics, grid, javascript, microsoft, selected items
Post a Comment