Cannot copy a row to another correctly


I have a grid, linked to a mysql database. Loading & Editing data is OK : everything is perfectly sync with database

I have two buttons in my ToolBar which are source of my message: Add (to add a new default row) and Copy, to clone the currently selected row.

Adding a default new row works fine using the following action:


Copy dot no work. I am using this code:

var id=liste_adherents.uid(); liste_adherents.addRow(id, ""); liste_adherents.copyRowContent(liste_adherents.getSelectedRowId(),id);

On the grid, the new line is created and source row is copied… but nothing is written in database.

Then, I tried to add a setUpdated on dataProcessor, to notify the updated status

var id=liste_adherents.uid(); liste_adherents.addRow(id, ""); liste_adherents.copyRowContent(liste_adherents.getSelectedRowId(),id); [b]dp_categories.setUpdated(id, true);[/b]

Now, on the grid a new line is created with the content of source row and data is sent to database, but with a problem: two entries are created in database: the first one is an empty entry (seems to come from the addRow() call as if I change to " liste_adherents.addRow(idRow, “test”);", this line contains “test” as a first data field), the second one is the actual clone of the source row. This can also be observed when reloading the page, forcing reload of database content.

Could somebody help me to understand why I have this behaviour and how to correctly clone a row and send it to database ?


To observe all this: … rents.html

PS: on my log file, two updates are sent to database, maybe the “id” is source of the problem… bu why ?:



I don’t know what was wrong in my previsou code, however, I found a workaround using “getRowId(getRowsNum()-1)” to force to get each time the row ID:

var idRow=liste_adherents.uid(); liste_adherents.addRow(idRow, ""); liste_adherents.copyRowContent(liste_adherents.getSelectedRowId(),liste_adherents.getRowId(liste_adherents.getRowsNum()-1)); dp_categories.setUpdated(liste_adherents.getRowId(liste_adherents.getRowsNum()-1), true);



well, mystake from myself… the previosu code was working because in my code I added an alert() popup… and this was the point : AddRow() followed by copyRow() was failing because the AddRow was not finished (transfer to database) before copy started…

This is corrected using the event onRowCreated:

var idRow=liste_adherents.uid(); liste_adherents.attachEvent("onRowCreated", function(rId){ liste_adherents.copyRowContent(liste_adherents.getSelectedRowId(),rId); dp_categories.setUpdated(rId, true); }); liste_adherents.addRow(idRow, "");