Dataprocessor synced to a grid and dhtmlXDataStore.
dataProcessor setUpdateMode(“off”);
custom onAfterUpdate event is set, to update the grid item to use the database auto-populated record id (id).
dp.attachEvent("onAfterUpdate", function(id, action, tid, response) {
if (action === 'inserted') {
/*
After creating row in the Grid, id is generated automaticaly,
that is way we should change it
*/
var obj = grid.getRowIndex(id);
grid.setRowId(obj, response.id);
/*
updating information in DataStore item
*/
var newItem = ds.item(id);
newItem.id = response.id;
ds.update(response.id, newItem);
}
return true;
});
adding a record like this (with default values) creates an issue is that upon adding a record, it is shown using “bold font” on the grid. but once calling dataProcessor sendData();
the data is saved correctly to the database and the grid still shows the new record as “bold”.
a 2nd call to sendData(); seems to make the bold go away.
ds.add({
'tracking': 'DefaultTracking',
'pieces': 1,
'packageType': 'DefaultType',
'id': 0
});
but, adding a record like this (without the string default values), just works fine!
ds.add({
'pieces': 1,
'id': 0
});
Any idea why is it?