Uncaught TypeError: Cannot read property 'isActive' of undefined
Uncaught TypeError: Cannot read property 'isActive' of undefined
othmanjadallah
Posts: 2Questions: 1Answers: 0
i have a problem
i need make a text base on database value in asp.net zero
im send the value from service to datatable but im see the message error same in the title
this my code
var getFilter = function () {
var filter = {
programName: $("#InstitutionFilter").val(),
programType: $("#InstitutionFilter").val(),
InstitutionName: $("#InstitutionFilter").val()
};
return filter;
}
var _programService = abp.services.app.program;
var _$programsTable = $("#ProgramsTable");
var dataTable = _$programsTable.DataTable({
paging: true,
serverSide: true,
processing: true,
listAction: {
ajaxFunction: _programService.getPrograms,
inputFilter: function () {
return getFilter();
}
},
columnDefs: [
{
className: 'control responsive',
orderable: false,
render: function () {
return '';
},
targets: 0
},
{
targets: 1,
data: null,
orderable: false,
autoWidth: false,
defaultContent: '',
rowAction: {
text: '<i class="fa fa-cog"></i> ' + app.localize('Actions') + ' <span class="caret"></span>',
items: [
{
text: function (data) {
if (data.record.isActive) {
return "DisActive"
} else {
return "Active"
}
},
action: function () {
}
}, {
text: app.localize('Delete'),
visible: function () {
},
action: function () {
}
}
]
}
},
{
targets: 2,
data: "programName"
},
{
targets: 3,
data: "programType"
}, {
targets: 4,
data: "institutionName"
}
]
});
function getProgram() {
dataTable.ajax.reload();
}
This discussion has been closed.
Answers
As far as I know Datatables doesn't have a configuration option
rowAction
. I'm not familiar with what it is doing but the error suggests the problem is here:Specifically
data.record.isActive
. Sounds like the error is indicatingdata.record
is undefined. Does data have the propertyrecord
? You can try usingconsole.log( data );
inside that function to see what data contains.Kevin