Add row when database is using auto_increment id

Dear members,

I have a little problem.
I use mygrid.addRow((new Date()).valueOf(),[’’,’’,’’,’’,false],-1)

My database got a first column named: “id” (auto_increment) set
Is there an addRow function who can handle that?

Thanks in advance,

Cheers Sander

If you are using connectors on server side , you need not care about client side ID for the new rows, such ID will be automatically replaced with ID from DB, after data saving.

Thanks for your reply Stanislav,

Aye, your right, but how should the addrow code look like?

Just like this wont work

First 2 parameters of addRow(new_id, text, ind) method are mandatory. Please check more information here docs.dhtmlx.com/doku.php?id=dhtm … ect_addrow

sorry but how should i be able to set that new_id parameter?
its automatically done server side with auto_increment

I will give you an example:

The delete button:

function delete() {
var answer = confirm(“Delete row??”)
if (answer){
alert(“Row Deleted!”)
mygrid.deleteSelectedItem();
}
else{
alert(“Row not deleted!”)
}
}

Above works perfect!!

The button to add a row just wont work:

It doesnt do anything

If you are using Connectors on sever side and send “insert” operation with random row id, such row id will be automatically replaced with ID from DB after data saving.

I think there is a problem with the addrow function somehow when using a button.

I gave as example the delete button and the addrow button (above your reply, i just edited it)

Delete button works like a charm, but addrow simply doesnt do anything

There is a typo at your code. Instead of

mygrid.addrow(newId, "");

you have to use

mygrid.addRow(newId, "");