Grid and keyed tables

Proposal is for inserting new rows.
For tables with primary key:

  • Allow to enter any value in a key column.
  • Throw an error message if keys are conflicting.
  • Allow table editing.

For tables without primary keys:

  • Do not allow table editing (make it read-only) but allow adding new rows.

This is a common behavior for many database front ends.
I would suggest to make this behavior as an option.

Current logic of dataprocessor is based on next assumptions
a) each data element ( row, event, item ) has ID which is unique and can be used to identify the element.
b) ID of element can be changed only during insert operation ( while adding new element ) , and it can be changed only on server side.

Giving ability to change ID of the element in the grid is definitely bad idea.

  • there is no way to guarantee its uniqueness
  • because ID can be changed by editing , it is not clear how updated data may be linked to the data in DB ( because they have not any common fields for linking )

For tables without primary keys:

  • Do not allow table editing (make it read-only) but allow adding new rows.
    You can set an “ID” parameter of render command as empty string - connector will be able to render such data, but any attempt to edit such data will result in grid - because client side data can’t be linked to data in DB. ( adding new data will work, because it need not ID for such operation - but its nearly useless, without ability to edit the same data )
  • Allow to enter any value in a key column.
  • Throw an error message if keys are conflicting.
  • Allow table editing.
    While connector doesn’t support such behavior automatically, it possible to extend its logic through server side events, so it will handler situation correctly. If necessary I can provide a sample code.

You can try to use the attached file - unzip it into the connector’s folder and you will be able to use new entity - KeyGridConnector

   require_once("../config.php");
   $res=mysql_connect($mysql_server,$mysql_user,$mysql_pass);
   mysql_select_db($mysql_db);

   require("../../codebase/keygrid_connector.php");
   $grid = new KeyGridConnector($res);
   $grid->enable_log("temp.log",true);
   $grid->render_table("test","a","a,b");

It works the same as normal grid connector, but it allows ( and requires ) that key field is not auto-increment, but an ordinary field, which is shown in grid as other fields.
scheduler_0102.zip (49.1 KB)

Same for java
dhtmlxconnector.zip (107 KB)