I am writing a bit of client side code to move data from one Infragistics UltraWebGrid to another. To do this I have given the user a button on each row of the main table. If they click the button in a row the contents of the id and descrition columns should be inserted into the destination grid.
This all should have been real simple. Except my javascript did not work. Here is my original code:
function OnClickCellButton(gridName, itemName)
{
var row = igtbl_getRowById(itemName);
if (row != null)
{
var gridrow=igtbl_getActiveRow("MergeGrid");
if(gridrow=null)
{
alert("gridrow is null");
//if no activerow then set one and add the row to the customers band
gridrow = igtbl_setActiveRow("MergeGrid",igtbl_getElementById ("MergeGridr_0"));
}
var groupNo = row.getCell(1).getValue();
var terms = row.getCell(3).getValue();
var newrow = igtbl_addNew("MergeGrid",0);
newrow.getCell(0).setValue(groupNo);
newrow.getCell(1).setValue(terms);
}
}
So the code is syntactically correct. My destination grid has an Id of MergeGrid. But remember my UltraWebGrid is on an UltraWebTab. This causes a problem. When I run this function, my row is never added to the grid. That is because behind the scenes, my grid was renamed. This is how I finally got the function to work.
Notice that I replaced the MergeGrid name with UltraWebTab1xxctl0xMergeGrid. I found this name by running my ASP.Net web project and viewing the source of the page from the web browser. There may be a better way to do this and if there is I'd like to know.
--chaz
function OnClickCellButton(gridName, itemName)
{
var row = igtbl_getRowById(itemName);
if (row != null)
{
var gridrow=igtbl_getActiveRow("UltraWebTab1xxctl0xMergeGrid");
if(gridrow=null)
{
alert("gridrow is null");
//if no activerow then set one and add the row to the customers band
gridrow = igtbl_setActiveRow("UltraWebTab1xxctl0xMergeGrid",igtbl_getElementById("UltraWebTab1xxctl0xMergeGridr_0"));
}
var groupNo = row.getCell(1).getValue();
var terms = row.getCell(3).getValue();
var newrow = igtbl_addNew("UltraWebTab1xxctl0xMergeGrid",0);
newrow.getCell(0).setValue(groupNo);
newrow.getCell(1).setValue(terms);
}
}