Changin data rows using a button

Changin data rows using a button

alang2205alang2205 Posts: 18Questions: 11Answers: 0

I am trying to do a simple datatable with 2 columns(Name, age) that look like this

NAME ** AGE **
Steve 15
John 20
Juan 31

The idea here is that with a button i can sum +10 to every table row,
After clicking the button without refreshing the page the table should dynamiclly change to look like this
NAME ** AGE **
Steve 25
John 30
Juan 41

Answers

  • colincolin Posts: 15,237Questions: 1Answers: 2,599
    edited April 2022

    If you want the data to persist a page refresh, you would need to store the data on a server, and request/send it via ajax. This is easily done using the Editor API - using edit() and field().set(). Without Editor, you would need to code that functionality yourself,

    Colin

  • alang2205alang2205 Posts: 18Questions: 11Answers: 0

    thanks Colin but that is not exactly what i want to do, the example you gave me it basically update the crud without refreshing i was looking for a button that alter the current data after clicking it, something like this
    NAME ** AGE **
    Steve 15
    John 20
    Juan 31 BUTTON

    *After clicking the button the dable should sum his values data to 10
    NAME ** AGE **
    Steve 25
    John 30
    Juan 41

  • kthorngrenkthorngren Posts: 21,184Questions: 26Answers: 4,925

    Use rows().every() to loop through all the rows. Use row().data() to get and set the data. Something like this:
    http://live.datatables.net/maquwaso/1/edit

    Kevin

Sign In or Register to comment.