回复 8楼xingyuan2010000的帖子
链接中的demo实现了每 1000 毫秒加载一批数据,单位是毫秒,并且在前台实现了数据加载提示。具体的做法是前台添加 label 用于显示。
感觉加载时间不稳定,请问数据是在本地还是远程服务器?有可能是由于网络原因影响的。
后台注册前台加载脚本:
- protected void Page_Load(object sender, EventArgs e)
- {
- string js = "var spid='" + FpSpread1.ClientID + "';";
- js += "var ss=document.getElementById(spid);" + "\r\n";
- js += "if (ss.addEventListener) {" + "\r\n";
- js += " ss.addEventListener("LoadRowsStart", RowStart, false);" + "\r\n";
- js += " ss.addEventListener("LoadRowsStopped", RowStop, false);" + "\r\n";
- js += "} else {" + "\r\n";
- js += " ss.onLoadRowsStart = RowStart;" + "\r\n";
- js += " ss.onLoadRowsStopped = RowStop;" + "\r\n";
- js += "}" + "\r\n";
- ClientScript.RegisterStartupScript(this.GetType(), "onStartUpScript", js, true);
- }
复制代码
前台脚本改变label值:
- <script type="text/javascript">
- function RowStart() {
- document.getElementById("<%= Label1.ClientID %>").innerHTML = "后台加载数据行...";
- }
- function RowStop(e) {
- var e = e || window.event;
- var rowsToBeLoaded = e.rowsToBeLoaded;
- if (rowsToBeLoaded == 0) {
- document.getElementById("<%= Label1.ClientID %>").innerHTML = "";
- }
- document.getElementById("<%= Label2.ClientID %>").innerHTML = rowsToBeLoaded;
- }
- </script>
复制代码 |