How do I get "data" in a click event handler?
How do I get "data" in a click event handler?

In the below code I'm trying to put a button (icon) in the cell(column) and trigger page location change on the Controller. I cannot seem to get "data" in the .click function on line 22. New in this arena so info help is appreciated.
columnDefs: [
{
className: 'control responsive',
orderable: false,
render: function () {
return '';
},
targets: 0
},
{
targets: 1,
data: null,
orderable: false,
defaultContent: '',
rowAction: {
element: $("<div/>")
.addClass("text-center")
.append($("<button/>")
.addClass("btn btn-outline-primary btn-sm btn-icon")
.attr("title", app.localize("Open Document"))
.append($("<i/>").addClass("la la-search"))
).click(function (data) {
document.location.href = abp.appPath + "App/CustomersAndAccounts/ViewCustomerDetail?id=1";
})
}
},
This question has accepted answers - jump to:
This discussion has been closed.
Answers
rowAction
isn't a configuration option so that won't work. This example shows how to add things to cells - in this case a link but buttons would be trivial with this.I don't understand that, sorry. Could you give more details, please.
Colin
Apologies.
"and trigger page location change on the Controller" is referring to the ASP.Net MVC architecture.
In the example below, in the RowAction, I have access to the "data.record" object.
However, in this example the action lives within a pop-up button labeled "Actions". I just don't want the pop-up button at all. Just a simple icon/button, not a collection of buttons ("items:")
btw, the answer you provided DOES work for me, i'm just lacking the understanding of why the "data" object becomes null in a click handler on my first example.
Thank you for the response.
I've seen
rowAction
in this forum before. Like Colin said its not a Datatables option. Its specific to a library you are using with Datatables. To debug problems withrowAction
you should contact the developer of the library that includes it.Kevin