Get all data for selected row(s)

Get all data for selected row(s)

canwejustcodecanwejustcode Posts: 34Questions: 9Answers: 0
edited February 6 in Free community support

I'm using the datatable and I have a checkbox in the first cell. The users can select the checkbox for a row they want to export. I'm able to get the value of the checkbox, however, I want to get all the values from everything in that selected row(s). I need to get the selected value from a dropdown, and value of the data entered into the textbox. Each row has a checkbox, dropdown and a text box..

I'm unable to post code due to the computer running the app with the datatable isn't connected to the outside internet. I'll try and see if I can post some code snippets

Thanks

Answers

  • kthorngrenkthorngren Posts: 21,080Questions: 26Answers: 4,908

    Are you using the Select extension with the select checkbox like this example? If so use the solution in this example to get the selected rows.

    The exact process to get the input values is dependent on how the inptus are built, ie, rendered in HTMl or using columns.render to render the inputs. The best option is to build a simple test case that shows exactly how you are building th inputs and the select checkbox. This way we can help by updating the example with code to show how to get the input values.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • canwejustcodecanwejustcode Posts: 34Questions: 9Answers: 0

    I'm using the checkbox, but not highlighted the entire row like that, I'm able to get the value of the checked checked box, as for the second example you have, I looked at that, but that doesn't show all of the data for the selected row, only says 1 row selected.

    I'll see if I can create a code (scaled down) snippet

  • kthorngrenkthorngren Posts: 21,080Questions: 26Answers: 4,908
    edited February 6

    but that doesn't show all of the data for the selected row, only says 1 row selected.

    The key point that example is demonstrating is to use the selector-modifier of { selected: true } to get only the selected rows. Use that with rows().data() to get the data, for example:

    var data = table.rows({ selected: true }).data();
    

    With that example you need to use shift-click or ctrl-click to select multiple rows. But this works only if you are using the Select extension.

    Kevin

  • canwejustcodecanwejustcode Posts: 34Questions: 9Answers: 0
    edited February 6

    I'm using a checkbox in the first column of every row to let the user select it, so they can check one checkbox or all of them, then click a button, that button will then grab the data from every selected row, and store into a table for processing a file. I have something like the example you have, though not giving me everything, (ie: dropdowns, textboxes), that URL you have is kicking out a 404 error.

    thanks

  • kthorngrenkthorngren Posts: 21,080Questions: 26Answers: 4,908

    that URL you have is kicking out a 404 error.

    Fixed.

    I have something like the example you have, though not giving me everything, (ie: dropdowns, textboxes), that URL

    I created this example a long time ago to show how to get the row data of all rows selected with standard checkboxes, ie, not using the Select extension.
    https://live.datatables.net/mutavegi/1/edit

    Since there is more than one way to generate the inputs we will need to see what you are doing to offer suggestions. Feel free to update my test case if you wish..

    Kevin

  • canwejustcodecanwejustcode Posts: 34Questions: 9Answers: 0

    Thanks, your example is exactly what I'm trying to accomplish I'll have to see how I can tie in the textboxes and the selected items for the dropdowns for each row. thx

Sign In or Register to comment.