DataTable Custom Button per Rows

Use this Forum to post your “How to …” questions about your use of aXes. This is not a technical support forum. Both the aXes Support Team at LANSA and other aXes customers may answer your questions. LANSA cannot guarantee the accuracy of any information posted by customers.

Moderator: jeanmichel

Post Reply
dylan.ramirez
Posts: 7
Joined: 15 Nov 2022, 16:03

DataTable Custom Button per Rows

Post by dylan.ramirez »

Hi,

Can anyone try to add custom button to a data table or change its column type to hyperlink to redirect or get data of specific row?

Thanks for helping and giving opinion.
Attachments
dt_screenshot.png
dt_screenshot.png (7.52 KiB) Viewed 6027 times
User avatar
Dino
Posts: 88
Joined: 19 May 2017, 08:29

Re: DataTable Custom Button per Rows

Post by Dino »

Hi,

While the use of datatables in aXes is mostly to just display data not really to interact with it,
according to this example:
https://datatables.net/examples/ajax/nu ... ource.html

you basically have to use this for columnDefs to get a button there:

Code: Select all

columnDefs: [
            {
                targets: -1,
                data: null,
                defaultContent: '<button>Click!</button>',
            },
which translates to aXes to go to columnDefs, edit it and put this code there:
datatables01.png
datatables01.png (146.33 KiB) Viewed 6022 times

Code: Select all

ENV.returnValue =  [
    {
        targets: -1,
        data: null,
        defaultContent: '<button>Click!</button>',
    },
];
to get this result:
datatables02.png
datatables02.png (88.64 KiB) Viewed 6022 times
now what to do with the onclick action and where to put that no idea but is supposed to be a code like this:

Code: Select all

$('#example tbody').on('click', 'button', function () {
        var data = table.row($(this).parents('tr')).data();
        alert(data[0] + "'s salary is: " + data[5]);
    });
.
dylan.ramirez
Posts: 7
Joined: 15 Nov 2022, 16:03

Re: DataTable Custom Button per Rows

Post by dylan.ramirez »

thanks for the help! I appreciate.
Post Reply