我正在使用jQuery jTable和' Slide In'效果,所以每次点击一个标签时,它都会带来数据' Slide In'过渡。但是,我最近关闭了分页' jQuery jTable中的功能,从那以后,幻灯片放入'转换卡在中间,同时发出以下消息" No Data Available"转换完成后,只有它带来数据。
非常奇怪......它在中间变得非常糟糕,在转换完成后它只会带来数据并且是一个主要问题。
在它带来数据之前,我有没有办法加载ajax?或者我可以使用任何其他过渡而不是毛刺'滑入'?
我从本地Excel文件中提取数据。任何帮助都非常感谢:)
滑入转换代码:
$(document).on('click', '.PlayStatisticClass', function (e) {
var $marginLefty = $("div[class='" + this.id + " win-ui-dark slide']")
if (!$marginLefty.hasClass('slide in')) {
if (this.id === "PlayStatisticone" || this.id === "PlayStatistictwo" || this.id === "PlayStatisticthree" || this.id === "PlayStatisticfour" || this.id === "PlayStatisticfive"
|| this.id === "PlayStatisticsix" || this.id === "PlayStatisticseven" || this.id === "PlayStatisticeight" || this.id === "PlayStatisticnine") {
$marginLefty.addClass('registrationFormSlideIn').css('width', "");
}
else {
}
}
else {
$marginLefty.removeClass('slide in').addClass('slide').css('width', 0);
}
});
jTable查看代码:我关闭了分页:
$(document).ready(function () {
$('#TopPlayedTracksContainer1').jtable({
title: 'Top Played Genres List',
paging: false,
pageSize: 1,
sorting: true,
defaultSorting: 'NoOfPlays DESC',
actions: {
listAction: '@Url.Action("BilingReportList")'
},
fields: {
TrackID: {
title: 'Track ID',
tooltip: 'Track ID'
},
TrackName: {
title: 'Track Name',
tooltip: 'Track Name',
key: true,
create: false,
edit: false,
resize: false,
},
ArtistName: {
title: 'Artist Name',
tooltip: 'Artist Name'
},
Times: {
title: 'Times',
tooltip: 'Times'
},
}
});
$('#TopPlayedTracksContainer1').jtable('load');
});
控制器代码:从本地excel文件获取数据:
public JsonResult BilingReportList(int jtStartIndex = 0, int jtPageSize = 0, string jtSorting = null)
{
try
{
if (Request.IsAuthenticated == true)
{
string Path = @"C:\\5Newwithdate.xls";
OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source= '" + Path + "';Extended Properties=" + (char)34 + "Excel 8.0;IMEX=1;" + (char)34 + "");
OleDbDataAdapter da = new OleDbDataAdapter("select * from [Sheet1$]", con);
System.Data.DataTable data = new System.Data.DataTable();
da.Fill(data);
con.Close();
List<TopPlayed> daa = new List<TopPlayed>();
foreach (DataRow p in data.Rows)
{
TopPlayed top = new TopPlayed()
{
TrackID = Convert.ToInt32(p.Field<double>("ID")),
TrackName = p.Field<string>("Track Name"),
ArtistName = p.Field<string>("Artist Name"),
Times = Convert.ToInt32(p.Field<double>("NoOfPlays"))
};
daa.Add(top);
}
var newlist = daa.OrderByDescending(i => i.Times).ToList();
return Json(new { Result = "OK", Records = newlist, TotalRecordCount = daa.Count });
}
return Json(new { Result = "ERROR" });
}
catch (Exception ex)
{
return Json(new { Result = "ERROR", Message = ex.Message });
}
}
答案 0 :(得分:2)
您需要删除这些参数:
int jtStartIndex = 0,int jtPageSize = 0,string jtSorting = null
public JsonResult BilingReportList()
{
try
{
if (Request.IsAuthenticated == true)
{
string Path = @"C:\\5Newwithdate.xls";
OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source= '" + Path + "';Extended Properties=" + (char)34 + "Excel 8.0;IMEX=1;" + (char)34 + "");
OleDbDataAdapter da = new OleDbDataAdapter("select * from [Sheet1$]", con);
System.Data.DataTable data = new System.Data.DataTable();
da.Fill(data);
con.Close();
List<TopPlayed> daa = new List<TopPlayed>();
foreach (DataRow p in data.Rows)
{
TopPlayed top = new TopPlayed()
{
TrackID = Convert.ToInt32(p.Field<double>("ID")),
TrackName = p.Field<string>("Track Name"),
ArtistName = p.Field<string>("Artist Name"),
Times = Convert.ToInt32(p.Field<double>("NoOfPlays"))
};
daa.Add(top);
}
var newlist = daa.OrderByDescending(i => i.Times).ToList();
return Json(new { Result = "OK", Records = newlist, TotalRecordCount = daa.Count });
}
return Json(new { Result = "ERROR" });
}
catch (Exception ex)
{
return Json(new { Result = "ERROR", Message = ex.Message });
}
}