Grid and dataprocessor problem

I have defined a grid on the server side like this:


if ($grid->is_select_mode())//code for loading data
        $grid->render_sql("select personid,id,datestart,dateend,leavetype_id from personnel_absence where personid = $personid","id","id,personid,datestart,dateend,leavetype_id");
    else //code for other operations - i.e. update/insert/delete
        $grid->render_table("personnel_absence","id","personid,datestart,dateend,leavetype_id");

If I understood correctly the docs, this means that the grid will only use the “else” part for the update/delete/insert operations.

But when I update a row then i see the following in the log:

DataProcessor object initialized
7_gr_id => 7
7_c0 => 7
7_c1 => 6
7_c2 => 0000-00-00
7_c3 => 2010-06-06
7_c4 => 2
7_!nativeeditor_status => updated
ids => 7

Undefined offset: 4 at C:\xampp\xampp\htdocs\codebase\connector\grid_connector.php line 263

Row data [7]
id => 7
personid => 7
datestart => 6
dateend => 0000-00-00
leavetype_id => 2010-06-06
 => 2
!nativeeditor_status => updated

UPDATE personnel_absence SET personid='7',datestart='6',dateend='0000-00-00',leavetype_id='2010-06-06' WHERE id='7'

Edit operation finished
0 => action:updated; sid:7; tid:7;

And of course the data in “personid” field is changed. If I include the “id” field in the “render_table” then the update command updates the ID field as well and I want to avoid that.

DataProcessor object initialized
7_gr_id => 7
7_c0 => 7
7_c1 => 6
7_c2 => 0000-00-00
7_c3 => 0000-00-00
7_c4 => 1
7_!nativeeditor_status => updated
ids => 7

Row data [7]
id => 7
personid => 6
datestart => 0000-00-00
dateend => 0000-00-00
leavetype_id => 1
!nativeeditor_status => updated

UPDATE personnel_absence SET id='7',personid='6',datestart='0000-00-00',dateend='0000-00-00',leavetype_id='1' WHERE id='7'

Can you point me to the right direction?

Thank you

When you are using two different queries for loading and saving - you need to be sure that both have the same order of fields ( otherwise it will break saving )

If you need to remove some field from saving , you can use

//before render_table
function filter_set($action){
$action->remove_field(“id”); //named field will not be included in saving operations
}
$grid->event->attach(“beforeProcessing”, filter_set);

Also, there is a special connector type - which can be used if you want to use record id as column’s value.

docs.dhtmlx.com/doku.php?id=dhtm … _connector

Thank you very much.