我在计算当前显示数据表中的行时遇到问题。 1)第一个问题是wrong number of current visible rows 2)第二个是wrong start number of visible rows。似乎数据表计数列的错误高度或类似的东西?
我正在使用dataTables.scroller.js 1.4.2和jquery.dataTables.js 1.10.11
数据表的设置:
function setupSearch() {
oJobAdSearchTable = $('#jobAdSearchTable').DataTable({
serverSide: true,
processing: true,
searching: false,
"footerCallback": function (row, data, start, end, display) {
},
"fnInitComplete": function (oSettings, json) {
},
fnDrawCallback: function () {
var blabla = 0;
},
scrollInfinite: true,
scrollX: true,
scrollY: 550,
scroller: {
loadingIndicator: true
},
fnServerParams: function (aoData) {
aoData["companyNameId"] = $("#inputCompanyNameId").val();
aoData["jobAdHeadingId"] = $("#inputJobAdHeadingId").val();
aoData["jobAdId"] = $("#inputJobAdId").val();
aoData["fromDate"] = moment($("#datepickerSearchFromDate").datepicker("getDate")).format("DD/MM/YYYY");
aoData["toDate"] = moment($("#datepickerSearchToDate").datepicker("getDate")).format("DD/MM/YYYY");
aoData["partnerId"] = $("#valPartnerId").val();
aoData["sessionId"] = $("#valSessionId").val();
aoData["numJobAds"] = $("#valNumJobAds").val();
aoData["lang"] = currentLanguage;
},
ajax: {
url: '/api/searchjobadinfinite/get'
}
});
};
这个发送请求到C#方法(对不起大量的代码,我不知道什么可以影响这个问题):
public dynamic Get()
{
DataTablePager<JobTitleModel> res = new DataTablePager<JobTitleModel>();
try
{
DateTime beginTime = DateTime.Now.ToLocalTime();
NameValueCollection nvc = HttpUtility.ParseQueryString(Request.RequestUri.Query);
DOAReports.Args.SearchJobAdsArgs searchArgs = new DOAReports.Args.SearchJobAdsArgs(nvc);
if (provider == null)
provider = new ClickMapProvider();
// Due to performance we use a low number
searchArgs.TopNum = 250;
DateTime beginSql = DateTime.Now.ToLocalTime();
List<JobTitleModel> searchList;
if (searchArgs.JobAdID != "")
searchList = provider.SearchJobAdIdInfinite(searchArgs);
else
searchList = provider.SearchJobAdsInfinite(searchArgs);
DateTime endSql = DateTime.Now.ToLocalTime();
int totalNum = 0;
if (CacheSessionProvider.Contains(KEY_SESSION_JOBAD_SEARH_NUM_TOTAL))
{
totalNum = Convert.ToInt32(CacheSessionProvider.Get(KEY_SESSION_JOBAD_SEARH_NUM_TOTAL));
}
else
{
totalNum = provider.NumJobAds(searchArgs);
CacheSessionProvider.Add(KEY_SESSION_JOBAD_SEARH_NUM_TOTAL, totalNum);
}
int totalNumFiltered = totalNum;
if (totalNumFiltered > searchArgs.TopNum)
totalNumFiltered = searchArgs.TopNum;
DateTime beginSerialize = DateTime.Now.ToLocalTime();
var result = from sl in searchList
select new[] { sl.CompanyName, sl.Title, Convert.ToString(sl.JobAdId), sl.ProductPackage, sl.DateCreated.ToShortDateString(), sl.DateExpired.ToShortDateString(), Convert.ToString(sl.NumAppearances), Convert.ToString(sl.NumViews), Convert.ToString(sl.NumActions), Convert.ToString(sl.NumInterested) + " (" + Convert.ToString(sl.NumApplications) + ")", Convert.ToString(sl.JobAdId) + "," + Convert.ToString(sl.PrevJobAdId) + "," + Convert.ToString(sl.NextJobAdId) };
DateTime endSerialize = DateTime.Now.ToLocalTime();
DateTime endTime = DateTime.Now.ToLocalTime();
System.Diagnostics.Debug.WriteLine("From: " + searchArgs.FromRow + ", TO: " + searchArgs.ToRow + ", Elapsed: " + (endTime - beginTime).ToString() + ", Sql: " + (endSql - beginSql).ToString() + ", Serialize: " + (endSerialize - beginSerialize).ToString());
DOAReports.Model.JobAdSearchTotal totals = provider.GetSearchJobAdInfiniteTotal(searchArgs);
return new
{
draw = searchArgs.draw,
recordsTotal = totalNum,
recordsFiltered = totalNumFiltered,
dataTotals = totals,
data = result
};
}
catch (Exception ex)
{
Logger.LogError(ex);
}
return res;
}
这个错误的原因是什么,你能帮帮我吗?我已经花了几天时间试图找到原因。非常感谢!