Primary key

Looks like dataProcessor assigns its own primary key (timestamp). Is it possible to force my own primary key values?


Could you please explain what primary key do you mean ?


DataProcessor sends row data that contains the actual row id. But ids must be unique. So if you doesn’t use unique ids when rows added, the ids are changed automatically.

I have a simple mysql table with column ‘id’ as a primary key. I am
adding a new row through grid. It puts “0” in ‘id’ column and debugger
says:

“row 1264178880418 marked [inserted,valid]”

Grid still shows 0 until I refresh the page. Then it shows 1264178880418, the same as in a table. 


row id is passed to the addRow method in the 1st parameter:


grid.addRow(rowId,[column1_value,column2_value,…,columnN]);


rowId must be unique (there shouldn’t be rows with the same ids in grid). In addition it’s better not to use rowID=0 (0 is the same as null in JS).


If you use dataprocessor and connector, after saving in database the row id in grid will be changed to the id of this row in database automatically.

t’s better not to use rowID=0
I do not. I click “add row” and “0” appears in grid automatically.

>row id in grid will be changed to the id of this row in database automatically.
No, it stays “0” until I refresh the whole page. See snapshot attached. I clicked on “add row” twice.



dataProcessor doesn’t change values in grid rows.


You can set the necessary value when you call addRow method:


var id = (new Date()).valueOf()


grid.addRow(id,[id,“value2”,…,“value N”]);

Maybe I am not explaining it clear. I would prefer “id” field to remain blank (just like other columns) when adding a new row. Then I can edit “id” field and put there any value I’m pleased. If there is a conflict I’d rather get an error message.
It could be some setting like
grid.allowIdBlank(true)
In this case column “id” must be populated first in case setUpdateMode(“cell”) or error will be displayed.

I would prefer “id” field to remain blank (just like other columns) when adding a new row
When row is added it must have some temporary ID ( because in other case it will be non-operable)
Dataprocessor assigns temporary ID and sends data to the database where it need to be replaced with actual ID during saving. ( in default samples it organized by auto-increment field in DB )

>>Grid still shows 0 until I refresh the page. Then it shows 1264178880418, the same as in a table.
Value of column ID in grid and value of row ID are different entities. When you are adding new row - there are two parameters ID and set of data
If you are using column which duplicates ID then server side code can be non-consistent, because it may receive different row_id and value of “id” column - so its not clear , which of them need to be used for DB operation.
As default rule - you must not use the same field for row_id and column of grid.