Error when not inserting all columns in a table.
Error when not inserting all columns in a table.
col.brazier
Posts: 26Questions: 2Answers: 0
Hi,
I am getting this error when trying to add a row.
"In the form that is used for adding new records cannot be found an input element with rel=0 that will be bound to the value in the column 0. "
and so on for all the text fields, except those for which I want to insert and I have specified rel. Column 0 is an auto increment field, and there are other columns I do not want to insert - do I have to specify every column in the table?
Thanks,
Colin
I am getting this error when trying to add a row.
"In the form that is used for adding new records cannot be found an input element with rel=0 that will be bound to the value in the column 0. "
and so on for all the text fields, except those for which I want to insert and I have specified rel. Column 0 is an auto increment field, and there are other columns I do not want to insert - do I have to specify every column in the table?
Thanks,
Colin
This discussion has been closed.
Replies
Colin
Your assumption is generally speaking correct - DataTables expects you to give it all of the data that it needs to show - i.e. a piece of data for each cell to be displayed. There isn't an ability to auto-increment like you would find in SQL, although it can be "faked" like in this example: http://datatables.net/release-datatables/examples/api/counter_column.html
The exception to this rule is that you can use the mDataProp option for a column to set the data source for that column to null. Then using fnRender or any other method (fnRowCallback etc) you can insert, programmatically, the data you want.
Another option, if you don't want to pass known data for a column, then you could give it either null or an empty string.
Regards,
Allan
I think we may be at cross purposes here. I can handle the auto increment programatically in my add_player.php file hopefully. What I was wondering is whether DataTables, when using the pop up version of adding a row, expects all columns in the table to be represented in the formAddNewRow form whether I am putting data in there or leaving them blank/null.
I have come across a different issue which I'll raise as another discussion.
Thanks and regards,
Colin