sorting html with sAjaxSource
sorting html with sAjaxSource
michael.lujan
Posts: 1Questions: 0Answers: 0
I am using sAjaxSource with asp.net and mvc.
Here is my code behind:
[code]
public JsonResult GetLibraries(int iDisplayStart, int iDisplayLength, string sSearch, bool bEscapeRegex, int iColumns, int iSortingCols, int iSortCol_0, string sSortDir_0, int sEcho) {
var query = _db.usp_provider__select_with_distributor();
List list = query.ToList();
var filteredList =
list
.Select(x => new[] { "" + x.distributor_name + "", "" + x.name + "", x.code, x.type.ToString(), x.status.ToString(), String.Format("{0:0,0}", x.total_cds), String.Format("{0:0,0}", x.total_tracks), String.Format("{0:0,0}", x.total_wavs), String.Format("{0:0,0}", x.total_mp3s), String.Format("{0:0,0}", x.total_jpg_s), String.Format("{0:0,0}", x.total_jpg_l), String.Format("{0:0,0}", x.size_in_gb), "Edit Manage" })
.Where(x => string.IsNullOrEmpty(sSearch) || x.Any(y => y.IndexOf(sSearch, StringComparison.InvariantCultureIgnoreCase) >= 0));
var orderedList = filteredList
.OrderByWithDirection(x => (x[iSortCol_0]).Parse(), sSortDir_0 == "desc")
.Skip(iDisplayStart)
.Take(iDisplayLength);
var model = new {
aaData = orderedList,
iTotalDisplayRecords = filteredList.Count(),
iTotalRecords = list.Count(),
sEcho = sEcho.ToString()
};
return Json(model);
}
[/code]
The problem is that the column's which contain html are not being sorted correctly, two questions, should I have this on the front end some how? Should I alter my backend to handle the creating of the links better?
Thanks.
Here is my code behind:
[code]
public JsonResult GetLibraries(int iDisplayStart, int iDisplayLength, string sSearch, bool bEscapeRegex, int iColumns, int iSortingCols, int iSortCol_0, string sSortDir_0, int sEcho) {
var query = _db.usp_provider__select_with_distributor();
List list = query.ToList();
var filteredList =
list
.Select(x => new[] { "" + x.distributor_name + "", "" + x.name + "", x.code, x.type.ToString(), x.status.ToString(), String.Format("{0:0,0}", x.total_cds), String.Format("{0:0,0}", x.total_tracks), String.Format("{0:0,0}", x.total_wavs), String.Format("{0:0,0}", x.total_mp3s), String.Format("{0:0,0}", x.total_jpg_s), String.Format("{0:0,0}", x.total_jpg_l), String.Format("{0:0,0}", x.size_in_gb), "Edit Manage" })
.Where(x => string.IsNullOrEmpty(sSearch) || x.Any(y => y.IndexOf(sSearch, StringComparison.InvariantCultureIgnoreCase) >= 0));
var orderedList = filteredList
.OrderByWithDirection(x => (x[iSortCol_0]).Parse(), sSortDir_0 == "desc")
.Skip(iDisplayStart)
.Take(iDisplayLength);
var model = new {
aaData = orderedList,
iTotalDisplayRecords = filteredList.Count(),
iTotalRecords = list.Count(),
sEcho = sEcho.ToString()
};
return Json(model);
}
[/code]
The problem is that the column's which contain html are not being sorted correctly, two questions, should I have this on the front end some how? Should I alter my backend to handle the creating of the links better?
Thanks.
This discussion has been closed.