I use the Datatables.mvc
for Crud operations in MVC.
for Edit, I'm sending ids to An action to rendering _EditPartial for editing.
in controller check's
If(Request.IsAjaxRequest)
// go to partialview...
but that it is always false! I checked every jquery libraries versions such as validate, unobtrusive-ajax and ... but still not working. I checked the headers of the request and there is no
X-Requested-With
Cshtml:
var assetListVM;
$(function () {
assetListVM = {
dt: null,
init: function () {
dt = $('#assets-data-table').DataTable({
language: {
url: '//cdn.datatables.net/plug-ins/1.10.19/i18n/Persian.json'
},
"serverSide": true,
"processing": true,
"ajax": {
"url": "@Url.Action("GetDepartments", "BaseInfo")",
},
"columns": [
{ "title": "نام دپارتمان", "data": "deptname", "searchable": true },
{ "title": "کد دپارتمان", "data": "deptCode", "searchable": true },
{ "title": "عکس", "data": "deptPic", "searchable": false, "sortable": false, },
{
"title": "actions",
"data": "deptId",
"searchable": false,
"sortable": false,
"render": function (data, type, full, meta) {
return '<a href="@Url.Action("EditDepartment", "baseinfo")?id=' + data + '" class="btn btn-app"><i class="fa fa-edit"></i> Edit</a> <a href="@Url.Action("DetailsDepartment", "BaseInfo")?id=' + data + '" class="btn btn-app"><i class="fa fa-file-text"></i> Details</a> <a href="@Url.Action("DeleteDepartments", "BaseInfo")?id=' + data + '" class="btn btn-app"><i class="fa fa-trash"></i> Delete</a>';
}
}
],
"lengthMenu": [[10, 25, 50, 100], [10, 25, 50, 100]],
});
},
refresh: function () {
dt.ajax.reload();
}
}
I copy these codes from a sample, in that sample everything work's fine and has X-Requested-With. what should I do? thanks.