How to edit multiple selected rows ?

How to edit multiple selected rows ?

user12user12 Posts: 17Questions: 4Answers: 0

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

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    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

  • user12user12 Posts: 17Questions: 4Answers: 0
    edited December 2021

    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.

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    And i dont want to use paid services.

    In that case, you will need to write the code yourself as Colin already said.

  • user12user12 Posts: 17Questions: 4Answers: 0
    edited December 2021

    I understand. But can you help me with this couse i dont know how can i update selected rows

  • kthorngrenkthorngren Posts: 21,337Questions: 26Answers: 4,954

    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 the selector-modifier of {selected: true}. If you only need to update locally you can just use row().data() to get the current data then row().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 the success function use ajax.reload() to refresh the table with the stored data.

    Kevin

  • user12user12 Posts: 17Questions: 4Answers: 0

    Can you do an example with my code? I need to save on server

  • kthorngrenkthorngren Posts: 21,337Questions: 26Answers: 4,954

    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

  • user12user12 Posts: 17Questions: 4Answers: 0

    http://live.datatables.net/ruhukame/1/

    This is what i have. And now i need to edit multiple rows, i mean checked rows.

  • kthorngrenkthorngren Posts: 21,337Questions: 26Answers: 4,954

    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

Sign In or Register to comment.