How to edit multiple selected rows ?
How to edit multiple selected rows ?
user12
Posts: 17Questions: 4Answers: 0
in DataTables
I am building a crm with laravel and i use datatables to show record from db, now i have a problem should i fix and need some help. I can check multiple rows but need to edit those multiple rows i have selected, exactly i need to edit jus a column of this row
the code is on file text
So what i need is to edit assign to colum for multiple rows where i select
Answers
The easiest way to do that would be to use Editor - multi-row editing has been included since version 1.6 - see example here.
Without it, you would need to implement that functionality within your code.
Colin
Thanks for answer. The example edit rows one by one. I need to select multiple rows at same time and to edit just assign_to column. And i dont want to use paid services.
In that case, you will need to write the code yourself as Colin already said.
I understand. But can you help me with this couse i dont know how can i update selected rows
If you want to use Editor you can use the
field().multiSet()
to set the values of multiple cells. See the example code at the bottom of the docs page.Or you can use
rows().every()
to iterate the selected rows using theselector-modifier
of{selected: true}
. If you only need to update locally you can just userow().data()
to get the current data thenrow().data()
to update the row. Or if you want to save the changes at a server you can a jQuery call with the updated data. Then in thesuccess
function useajax.reload()
to refresh the table with the stored data.Kevin
Can you do an example with my code? I need to save on server
Please start by creating a test case with what you have and how you are going to edit the rows. This will give us a better idea to help with offering suggestions.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
http://live.datatables.net/ruhukame/1/
This is what i have. And now i need to edit multiple rows, i mean checked rows.
I've made some assumptions. Looks like you want to use the Select extension with the select checkbox. So I removed the input you have for each row and added the Select extension JS and CSS. Also moved the code to enable the select checkbox into the Datatables initialization.
I added a button click event and in the event use
rows().every()
, as described above, to loop all the selected rows. It updates the Office column and places the results in array that is sent to the server via ajax.I commented out the ajax request but it shows sending the updatedData array and in the success function using
ajax.reload()
.Kevin