3.2.0

add new row to grid problem

Hello,
I'm trying to do so, that if user presses a keyboard key while being o nthe last row of the grid then a new row is added to the grid automatically. If user presses key not on the lat row then new row is not added. I have the code below which almost works but it has errors. The problem is that i got javascript error. If i press key on the last row the new row is added but the data, i mean the key i pressed, is lost on the row. Looks like i loose focus and the key i typed i never put into a cell. Can you help somehow, my code is below:



var row = obj.getTemplate("row");
row.setEvent("onkeydown",function(){this.action("myAction")});
obj.setAction("myAction",function(src){
//if user pressed key on the last row, then add new empty row:

if( parseInt(myData.length) == parseInt(parseInt(src.getProperty("item/index")) + 1) )
{
addRow(obj, myData);
}
});




var idCounter = -1;
function addRow(obj)
{
var rowData = defaultRow;

rowData[0] = idCounter;
idCounter--;

rowCount = myData.length;
myData[rowCount] = new Array();

myData[rowCount][0] = rowData[0];

obj.setRowProperty("count", myData.length);

updateHiddenFunc();
obj.refresh();
}
Charles Roos
May 11,
If i press on the last row a key down i am added a new empty row on the grid. But the key i pressed is gone, it's not visible in the previous row vell where keydown event was fired. This is the problem need to be solved.

But after i have added new row javascript have't give an error yet. If i click with mouse on any row now, after a new row was added, then javascript gives me error:

'editor.element().value' is null or not an object.

Can somebody help, what's wrong with my code?
Charles Roos
May 11,

This topic is archived.

See also:


Back to support forum