Data in all added rows is same
I am evaluating grid control. I need to populate rows in the grid dynamically. Initially I developed a sample and it is working fine. Same code (with some necessary modifications) I inserted in main project and it is giving me a problem. When I add a new row using "addRow" method, it does not get populated in grid control. "addRow" method is called in loop to fill grid completely. When loop is executed 5 - 6 times, 5 - 6 entries are added to grid at a time. When loop move forward after this, after each row added, data in all above rows becomes same as that in newly added row.
I was facing same problem while developing sample application. But I modified some code and the problem was solved. I donot remember now, what modification I was done.
Can anyone please help me solving this ?
My code is as follow :-
var objGrid = new AW.UI.Grid;
var dataRowArray = new Array();
var colnames = new Array(20);
var columnCount;
//ATTACH EVENTS TO OBJECT
objGrid.onRowAdded = function(row){setRowData(this);};
//FUNCTION DEFINITIONS
function initGridControl()
{
var num = new AW.Formats.Number;
num.setTextFormat("#,###.");
dataRowArray = new Array(columnCount);
//colnames = new Array(columnCount);
objGrid.setSize(850, 300);
objGrid.setId("Worklistview");
objGrid.setHeaderText(colnames);
objGrid.setCellFormat(num, 2);
objGrid.setColumnCount(columnCount);
objGrid.setRowCount(0);
objGrid.setRowHeight(25);
objGrid.setCellEditable(false);
//Set selecter column
objGrid.setSelectorVisible(false);
objGrid.setSelectorText("*");
objGrid.setSelectorWidth(28);
objGrid.setHeaderHeight(20);
//objGrid.setSelectionMode(true);
objGrid.setSelectionMode("single-row");
document.write(objGrid); //Display object on browser
objGrid.refresh();
}
function addRecord(recordData)
{
dataRowArray = recordData;
objGrid.addRow(objGrid.getRowCount());
}
function setRowData(newRowHandle)
{
try
{
//newRowHandle.setCellData(dataRowArray);
//newRowHandle.setCellText(dataRowArray, objGrid.getRowCount() - 1, newRowHandle);
newRowHandle.setCellText(dataRowArray, objGrid.getRowCount() - 1);
}
catch(e)
{
alert('Error : ' + e.description);
}
}
I was facing same problem while developing sample application. But I modified some code and the problem was solved. I donot remember now, what modification I was done.
Can anyone please help me solving this ?
My code is as follow :-
var objGrid = new AW.UI.Grid;
var dataRowArray = new Array();
var colnames = new Array(20);
var columnCount;
//ATTACH EVENTS TO OBJECT
objGrid.onRowAdded = function(row){setRowData(this);};
//FUNCTION DEFINITIONS
function initGridControl()
{
var num = new AW.Formats.Number;
num.setTextFormat("#,###.");
dataRowArray = new Array(columnCount);
//colnames = new Array(columnCount);
objGrid.setSize(850, 300);
objGrid.setId("Worklistview");
objGrid.setHeaderText(colnames);
objGrid.setCellFormat(num, 2);
objGrid.setColumnCount(columnCount);
objGrid.setRowCount(0);
objGrid.setRowHeight(25);
objGrid.setCellEditable(false);
//Set selecter column
objGrid.setSelectorVisible(false);
objGrid.setSelectorText("*");
objGrid.setSelectorWidth(28);
objGrid.setHeaderHeight(20);
//objGrid.setSelectionMode(true);
objGrid.setSelectionMode("single-row");
document.write(objGrid); //Display object on browser
objGrid.refresh();
}
function addRecord(recordData)
{
dataRowArray = recordData;
objGrid.addRow(objGrid.getRowCount());
}
function setRowData(newRowHandle)
{
try
{
//newRowHandle.setCellData(dataRowArray);
//newRowHandle.setCellText(dataRowArray, objGrid.getRowCount() - 1, newRowHandle);
newRowHandle.setCellText(dataRowArray, objGrid.getRowCount() - 1);
}
catch(e)
{
alert('Error : ' + e.description);
}
}
Amit Joshi
January 29,