|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
Introduction
Code sample for navigating through ASP DataGridfunction NavigatingDataGrid(oDataGrid)
{
for(j = 0; j < oDataGrid.childNodes.length; j++)
{
var tBody = oDataGrid.childNodes(j);
for(k=0;k < tBody.childNodes.length-1; k++)
{
var tr = tBody.childNodes(k);
for(l=0; l < tr.childNodes.length-1; l++)
{
td = tr.childNodes(l);
//loop through the column and do the validation as required
//if there is any control inside the Column access the control
//by gettting the childNodes of the column
}
}
}
}
Code explanationThe cells in the Code sample for navigating through Infragistics WebGridAdding rows in Infragistics WebGrid when data is entered in the last rowfunction AfterCellUpdate(gridName,cellId)
{
var row = igtbl_getRowById(cellId);
var grid = igtbl_getGridById(gridName);
var band = row.Band
var col = igtbl_getColumnById(cellId);
if (band.Key == 'Parent')
{
if (row.getIndex() == grid.Rows.length-1)
{
igtbl_addNew(gridName,0);
var lastrow = row.getNextRow;
igtbl_addNew(gridName,1);
}
}
if (band.Key == 'Child')
{
if (row.getIndex() == row.ParentRow.Rows.length-1)
{
igtbl_addNew(gridName,1);
}
}
}
Detecting the keystroke on the client scriptfunction KeyDown(gn,cellId,KeyStroke)
{
if (KeyStroke == 46)
{
var row = igtbl_getRowById(cellId);
var grid = igtbl_getGridById(gn);
var band = row.Band;
if (band.Key == 'Parent')
{
return true;
}
}
if (band.Key == 'Child')
{
if (row.getIndex() == row.ParentRow.Rows.length-1)
{
return true;
}
}
}
Dynamically changing the dropdown value of a cell based on the value selected on other rowsfunction BeforeEnterEdit(tableName,cellName)
{
var col = igtbl_getColumnById(cellName);
var cell = igtbl_getCellById(cellName);
var grid = igtbl_getGridById('WGA');
var row = igtbl_getRowById(cellName);
var rowno = row.getIndex();
if ((col != null) && (col.Key == 'StateDefinitionID'))
{
var blnAddKey;
var cell1;
var i; var j = 0; var row1;
var index = col.Index;
var vlist = new Array();
var vlistold = new Array();
var vkey = new Array();
for (var key in LookUp)
{
vlistold[j] = new Array (key,LookUp[key]['Name']);
j++;
}
vlistold[j] = new Array ('0',' ');
j = 0;
col.ValueList = vlistold;
for (i=0;i<grid.Rows.length;i++)
{
row1 = grid.Rows.getRow(i);
cell1 = row1.getCell(index);
if ((cell1.getValue() != 0) && (rowno != row1.getIndex()))
{
vkey[j] = cell1.getValue();
j++;
}
}
j = 0;
for (var key in LookUp)
{
blnAddKey = true;
for (var l = 0;l < vkey.length;l++)
{
if (key == vkey[l])
{
blnAddKey = false;
break;
}
}
if (blnAddKey == true)
{
vlist[j] = new Array(key,LookUp[key]['Name']);
j++;
}
}
vlist[j] = new Array ('0',' ');
col.ValueList = vlist
}
}
Code explanationFor Infragistics client events, the events can be set at design time in the client side script or can be defined dynamically. Either way once the client side events for the above functions are defined (the events name will be same as the function name) the client events will be associated with the grid. The first example shows how to add additional rows on the grid, when data is entered in the last row of the grid. The The second example shows how to trap the The last example is the unique requirement I had in my project where the dropdown value in one of the columns can't be selected twice. This code will remove the selected value(s) from the drop down and before the column enters into the edit mode sets the drop down value. This code can be modified to make drop down dynamic as per our business requirements. The array ConclusionHope this sample code is useful for developers who want to navigate through
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||