TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Asht T
913
866
14.5k
Jquery Datatatable MVC not working After publish IIS
Dec 14 2020 4:35 AM
MVC Application
Jquery datatable work fine in MVC Application but after publish and host on IIS then Jquery datatable not working.
My View Binding Code :
@* Load datatable css @ @*<link href=
"//cdn.datatables.net/1.10.9/css/jquery.dataTables.min.css"
rel=
"stylesheet"
/>*@ <link href=
"~/Content/DataTable/jquery.dataTables.min.css"
rel=
"stylesheet"
/> @ Load datatable js *@ @section Scripts{
@*<script src=
"//cdn.datatables.net/1.10.9/js/jquery.dataTables.min.js"
></script>*@
<script src=
"~/Scripts/DataTable/jquery.dataTables.min.js"
></script>
<script>
$(document).ready(
function
() {
//jQuery DataTables initialization
$(
'#myTable'
).DataTable({
"processing"
:
true
,
// for show processing bar
"serverSide"
:
true
,
// for process on server side
"orderMulti"
:
false
,
// for disable multi column order
"filter"
:
true
,
//"dom": '<"top"i>rt<"bottom"lp><"clear">',
"ajax"
: {
"url"
:
"/CountryMaster/LoadData"
,
"type"
:
"POST"
,
"datatype"
:
"json"
},
"columns"
: [
{
"data"
:
"CountryName"
,
"name"
:
"CountryName"
,
"autoWidth"
:
true
},
//index 0
{
"data"
:
"CountryId"
,
"width"
:
"50px"
,
"render"
:
function
(data) {
return
'<a class="popup" href="/CountryMaster/Edit/'
+ data +
'">Edit</a>'
;
}
}
]
});
});
</script>
}
Controller Code
[HttpPost]
public
ActionResult LoadData()
{
//Get parameters
// get Start (paging start index) and length (page size for paging)
string
Search = Request.Form.GetValues(
"search[value]"
)[0];
var draw = Request.Form.GetValues(
"draw"
).FirstOrDefault();
var start = Request.Form.GetValues(
"start"
).FirstOrDefault();
var length = Request.Form.GetValues(
"length"
).FirstOrDefault();
//Get Sort columns value
var sortColumn = Request.Form.GetValues(
"columns["
+ Request.Form.GetValues(
"order[0][column]"
).FirstOrDefault() +
"][name]"
).FirstOrDefault();
var sortColumnDir = Request.Form.GetValues(
"order[0][dir]"
).FirstOrDefault();
//find search columns info
int
pageSize = length !=
null
? Convert.ToInt32(length) : 0;
int
skip = start !=
null
? Convert.ToInt32(start) : 0;
int
totalRecords = 0;
using
(CountryEntities dc =
new
CountryEntities())
{
dc.Configuration.LazyLoadingEnabled =
false
;
// var v = (from a in dc.tblCountry select a);
var ad = (from dm
in
db.tblCountry
select
new
{
dm.CountryName,
dm.CountryID,
}).ToList();
//Sorting
var v = (from a
in
dc.tblCountry orderby a.countryID select a).AsQueryable();
// SEARCHING...
if
(!
string
.IsNullOrEmpty(Search))
{
v = v.Where(a => a.CountryName.Contains(Search.ToLower()));
}
//Sorting
if
(sortColumn!=
""
)
{
if
(!(
string
.IsNullOrEmpty(sortColumn) &&
string
.IsNullOrEmpty(sortColumnDir)))
{
v = v.OrderBy(sortColumn +
" "
+ sortColumnDir);
}
}
totalRecords = v.Count();
var data = v.Skip(skip).Take(pageSize).ToList();
return
Json(
new
{ draw = draw, recordsFiltered = totalRecords, recordsTotal = totalRecords, data = data }, JsonRequestBehavior.AllowGet);
}
}
Reply
Answers (
2
)
Creating subreport in cystal report
How to remove miscellaneous files in visual studio2019.