Access selected rows with custom button

Access selected rows with custom button

klinglerklingler Posts: 90Questions: 42Answers: 2

Good day (o;

I've seen the example of adding a custom button to datatables editor and would like to know:

  1. How can I disable the button if no row is selected?

  2. How do I actually get the data of the selected rows? I see only the data() API call which returns all rows...

thanks in advance
richard

Answers

  • kthorngrenkthorngren Posts: 21,170Questions: 26Answers: 4,922

    How can I disable the button if no row is selected?

    You can use selected or selectedSingle. See this example.

    How do I actually get the data of the selected rows? I see only the data() API call which returns all rows...

    This example shows how to get selected rows.

    Kevin

  • klinglerklingler Posts: 90Questions: 42Answers: 2

    Hello Kevin

    Thanks....works great :-)

    Using something like:

                    {
                        extend: "selected",
                        text: 'Move...',
                        action: function () {
                            var rows = table.rows( { selected: true } ).data().each(element => console.log(element));
                    }
    
This discussion has been closed.