Why doesn't the New button do anything
Why doesn't the New button do anything
spickens
Posts: 24Questions: 7Answers: 0
New to editor. I am adding editor to an existing datatable that works well. The code is shown below. When I click on the Add button, nothing happens. There is no error on the console.
<script type = "text/javascript">
$(document).ajaxError(function (event, xhr, options, exc) {
alert(exc.toString());
});
var jdata;
var columnsx =
[
{ "data": "SALUTATION", "name": "SALUTATION", "autoWidth": true },
{ "data": "FIRSTNAME", "name": "FIRSTNAME", "autoWidth": true },
{ "data": "LASTNAME", "name": "LASTNAME", "autoWidth": true },
{ "data": "USERNAME", "name": "USERNAME", "autoWidth": true },
{ "data": "ENABLED", "name": "ENABLED", "autoWidth": true }
];
$(document).ready(function () {
editor = new $.fn.dataTable.Editor({
ajax: {
create: "ItemAnalysis.aspx/AddUser",
type: "POST",
dataType: "json",
contentType: "application/json",
data: function (d) {
return JSON.stringify(d);
},
table: "#userListGrid",
},
fields: [{
label: "Salutation:",
name: "SALUTATION"
}, {
label: "First Name:",
name: "FIRSTNAME"
},
{
label: "Last Name:",
name: "LASTNAME"
}, {
label: "User Name:",
name: "USERNAME"
}, {
label: "Enabled?:",
name: "ENABLED"
}]
});
$.ajax({
url: "UserList.aspx/LoadColumns",
type: "POST",
dataType: "json",
contentType: "application/json",
success: function (json) {
var temp;
temp = JSON.parse(json.d);
columnsx = temp;
$("#userListGrid").DataTable({
dom: 'Bfrtip',
select: true,
buttons: [
'copy', 'csv', 'excel', 'pdf', 'print',
{ extend: "create", editor: editor }
],
"processing": true,
"serverSide": false,
"pageLength": 25,
"paging": true,
"ajax": {
"url": "UserList.aspx/LoadData",
"type": "POST",
"datatype": "json",
"error": "ajaxError",
"contentType": "application/json",
"dataSrc": function (json) {
var temp;
temp = JSON.parse(json.d);
return temp;
}
},
"columns": columnsx
});
},
error: function () {
alert("Load Columns Failed");
}
});
});
This discussion has been closed.
Answers
The application was missing a reference to a .CSS file. Case closed.