Hi dear support,
i'm still here.
I need to now how to make a function for calling ajax on button row click.
I had rendered a button in grid, but I can't call a function.
{
title: "Assegna", dataType: "string", align: "center", dataIndx: "assegna", maxWidth: 50, render: function (ui) {
var rowData = ui.rowData,
dataIndx = ui.dataIndx;
rowData.pq_cellcls = rowData.pq_cellcls || {};
if (rowData.stato == "In Attesa" & rowData.assegna == "Assegnare Si") {
return "<a title='Click for assign to user' onClick='assignFunction();' class='btn btn-sm btn-light btn_assegna_direct' ><i class='fas fa-plus'></i> </a>";
function assignFunction() {
$.ajax({
contentType: "application/json; charset=utf-8",
data: '{"id_product" : "' + rowData.id_product+ '", "id_user" : "' + rowData.id_user+ '"}',
dataType: "json",
type: "POST",
url: "page.aspx/AssignProduct",
async: false,
success: function (result) {
msg += 'Product assigned';
},
error: function (result) { }
});
alert(msg);
}
} else {
return "<a title='Impossible to assign' class='btn btn-sm btn-secondary disabled'> <i class='fas fa-check'></i> </a>";
}
}
},