3.2.0

Add row on csv based grid.

Hi Alex

I have now used the array based grid for some time now, i'm starting to use csv based grid, and it was also working well with editing and saving, but i am almost out of hair now, when doing and addRow on a csv based grid it's doing something funny, below is the addRow function i use for test.

function addRow(){
var i = grid.getRowCount()

alert(grid.getRowCount())
grid.addRow(i);
alert(grid.getRowCount())
}

If i have a grid with 1 loaded row, and do the addRow 3 times the alert result is :

1: alert(1) and alert(11)
2: alert(11) and alert(111)
3: alert(111) and alert(1111)

Result after add, grid contains 1111 rows.

If i have a grid with 5 loaded rows, and do the addRow 3 times the alert result is :

1: alert(5) and alert(51)
2: alert(51) and alert(511)
3: alert(511) and alert(5111)

Result after add, grid contains 5111 rows.

Please help before i loose the rest of my hair.

Flaffer
Flaffer
June 8,
Seems like for some reason variable i becomes a string instead of a number, maybe adding i=Number(i) could fix it (I will look how to fix this bug properly)?
Alex (ActiveWidgets)
June 8,
Hi Alex,

I have tried with :

var i = Number(grid.getRowCount())

I have verified that i is a number before calling addrow by:

alert(grid.getRowCount())

alert(i)
i++
alert(i)
i--
alert(i)

grid.addRow(i);
alert(grid.getRowCount())

It seams that the string thing happens inside addRow(), has anybody used addRow on a csv grid, please.
Flaffer
June 9,
Hi Alex

Can you tell me if there is done anything about this, or give me an working example with CSV.table with addRow, please the deadline i closing and i need to know if i need to take another approach and reprogram.
Flaffer
June 12,
Could it be that you have set rowCount as string somewhere in your code, like

grid.setRowCount('1');

???
Alex (ActiveWidgets)
June 12,
Not quite like that but almost, when you look for something you get blind, thanks very much Alex, found the problem.
Flaffer
June 12,

This topic is archived.

See also:


Back to support forum