Set Custom id for every cell
Set Custom id for every cell
![cent89](https://secure.gravatar.com/avatar/7fb40900f79c08429ae628894c53b111/?default=https%3A%2F%2Fvanillicon.com%2F7fb40900f79c08429ae628894c53b111_200.png&rating=g&size=120)
Hi,
I have a table ("subscriptions") with the list of user subscribed to a site; I have attached to this table some columns: the number is dynamic.
The values of this colums ara taken from another table, where I have the id of the columns and the value (and the row id as primary key). So, any cells in the rendered table have a "custom" id, not the row id.
In the php controller, after the main sql to subscriptions table, I have a loop that add a column and for every row it search the correct value in the db: for 3 lines and 2 columns like below, I have the main sql and other 6 query.
How I can set, in the editor, the cell's id so when I edit the cell the controller can edit the correct value?
--------------------------------------------------------------------------
|| Id_row | Username | Col_A | Col_B | ....||
-------------------------------------------------------------------------
|| 1 | Frank | a (cell.id = 1) | b (cell.id = 2) | ...||
|| 2 | Mario | c (cell.id = 3) | d (cell.id = 4) | ...||
|| 3 | Frank | e (cell.id = 5) | e (cell.id = 6) | ...||
-------------------------------------------------------------------------
Thanks!
Roberto
Answers
Hi @cent89 ,
This looks like the join table in the example here. Have you tried implementing like this?
Cheers,
Colin
Hi,
I can't use joins: for one subscriptions row, i have moltiple rows (one for every columns) in a "specifications" table.
I have already done the render of the datatable, the problem is the editor...
Thanks!
Roberto
Hi Roberto,
You would need to use a standalone Editor such as this. The DataTables configured Editor will not work the way you are looking to use it.
Allan
Sounds good.
But in my case in one panel/row table I have multiple fileds with the same name "value".
So, in the sql data I can rename the name, but when I create the editor, somethings goes wrong.
Some code:
PHP (Laravel controller)
JS
Mmmm...
I have build a Standalone editor, with a simple html table.
I can open the editor when I click on the "Edit" button but I'm getting ad error when I save the record:
Logging the data with a preSubmit(), the data field is an Object, not in json format:
The code in a cell table is:
Can you help me? Thanks!
I'm not familiar with that code I'm afraid. It sounds like an unhandled null, but I'm not sure. Possibly it might be caused by:
Could you give me a link to the page showing that so I can take a look and see what is going wrong?
Thanks,
Allan
Yes:
http://51.38.124.243/webtag/iscrizione?id_servizio=1
I'm getting:
when I load that page. Is that not what you are seeing?
Allan
Ok, It's the row id, not the cell id. Even if I add the correct id, the error in the console is the same:
DataTableEditor::editRules() must be an instance of Illuminate\Database\Eloquent\Model, null given
Thanks,
Roberto
That's still an error in the server-side code that you are using, and I'm not sure what that is. I'm also still getting a tn/4 error when I load the link above, so I'm not sure how to recreate the error.
Allan