read checkboxes value as id user
read checkboxes value as id user
I need an advice.
I am using checkboxes.
Have a lot of members.
They can choose a max. of 25 members they like to follow. It is saved in a string in the database.
Now I want the value of the checkboxes as the user_id's.
So I can check a string from a member in the database with numbers of id's.
If the number of the checkbox is in the string it has to be checked.
Otherwise it has to be unchecked.
I think it has to be done in the render function.
I can use a hidden column with the id's.
But maybe with rendering, the ID column can be rendered too.
Till now I am using this link (but works with on.click)
http://pctraverse.nl/DataTables-1.10.11/examples/server_side/simpleZ.html
Answers
I have one answer already.
But I still needed a simple script to sort on checked and not checked.
It sorts now on the ID.
Even if I tried 'full.id = '1' for checked and full.id = '0' for unchecked.
FROM MY DATABASE
IN MY SCRIPT (the class and value is not needed)
Why not add user_id to the tr element as an identifier? You can then save this in your database along with value of checkbox. So you save only user_id's that a user has checked and mark these accordingly within DataTable.
For sorting, try this trick.
--- or ---
Add https://datatables.net/reference/option/columns.type to this column with your own custom corting function
Thanks for the reply Gordon.
I already make a string on the user_id in my database as I showed with $my_var.
The given function works oke.
And I'm using the costum_id's. The rendering is in the column of the ID's.
But with the normal sorting it takes the given ID's.
I will try your options, thank you.