I don't know why allways show Processing..
I don't know why allways show Processing..
xxxx.aspx
[code]
$(document).ready(function(){
$('#example').dataTable({
"oLanguage": {
"sUrl": "../language/zh_CN.txt"
},
"iDisplayLength":10,
"sDom": 'C<"clear">lfrtip',
"oColVis": {
"activate": "mouseover"
},
"bJQueryUI": true,
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "../common/ajaxTable.aspx",
"aaSorting":[[1,"asc"]],
"fnServerData": function ( sSource, aoData, fnCallback ) {
$.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": fnCallback
} );
}
});
});
[/code]
ajaxTable.aspx.cs
[code]
protected void Page_Load(object sender, EventArgs e)
{
string iDisplayStart; //显示的起始索引
string iDisplayLength; //显示的行数
//int iColumns; //显示的列数
//string sSearch; //全局搜索字段
//boolean bEscapeRegex; //全局搜索是否正则
////boolean bSortable_(int) 表示一列是否在客户端被标志位可排序
////boolean bSearchable_(int) 表示一列是否在客户端被标志位可搜索
//string sSearch_; //个别列的搜索
////boolean bEscapeRegex_(int) 个别列是否使用正则搜索
//int iSortingCols; //排序的列数
//int iSortCol_; //被排序的列
//string sSortDir; //(int) 排序的方向 "desc" 或者 "asc".
//string sEcho; //DataTables 用来生成的信息
if (Request.Form["sEcho"] != null)
{
iDisplayStart = Request.Form["iDisplayStart"].ToString();
iDisplayLength = Request.Form["iDisplayLength"].ToString();
int sEcho = int.Parse(Request.Form["sEcho"].Trim());
DataSet ds = BLL.UserBll.getUser(iDisplayStart, iDisplayLength);
JsonHelper jsonHelp = new JsonHelper();
jsonHelp._sEcho = sEcho;
jsonHelp._iTotalRecords = ds.Tables[0].Rows.Count;
jsonHelp._iTotalDisplayRecords = ds.Tables[0].Rows.Count - 2;
if (ds != null)
{
DataTable DTable = ds.Tables[0];
for (int i = 0; i < DTable.Rows.Count; i++)
{
// 循环生成JSON代码 ==
foreach (DataRow item in DTable.Rows)
{
int cc = 0;
jsonHelp.AddItem(item[i].ToString());
cc++;
}
jsonHelp.ItemOk();
}
}
//Response.ContentType = "text/html";
Response.Write(jsonHelp.ToString();); // 输出JSON代码
}
}
[/code]
[code]
$(document).ready(function(){
$('#example').dataTable({
"oLanguage": {
"sUrl": "../language/zh_CN.txt"
},
"iDisplayLength":10,
"sDom": 'C<"clear">lfrtip',
"oColVis": {
"activate": "mouseover"
},
"bJQueryUI": true,
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "../common/ajaxTable.aspx",
"aaSorting":[[1,"asc"]],
"fnServerData": function ( sSource, aoData, fnCallback ) {
$.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": fnCallback
} );
}
});
});
[/code]
ajaxTable.aspx.cs
[code]
protected void Page_Load(object sender, EventArgs e)
{
string iDisplayStart; //显示的起始索引
string iDisplayLength; //显示的行数
//int iColumns; //显示的列数
//string sSearch; //全局搜索字段
//boolean bEscapeRegex; //全局搜索是否正则
////boolean bSortable_(int) 表示一列是否在客户端被标志位可排序
////boolean bSearchable_(int) 表示一列是否在客户端被标志位可搜索
//string sSearch_; //个别列的搜索
////boolean bEscapeRegex_(int) 个别列是否使用正则搜索
//int iSortingCols; //排序的列数
//int iSortCol_; //被排序的列
//string sSortDir; //(int) 排序的方向 "desc" 或者 "asc".
//string sEcho; //DataTables 用来生成的信息
if (Request.Form["sEcho"] != null)
{
iDisplayStart = Request.Form["iDisplayStart"].ToString();
iDisplayLength = Request.Form["iDisplayLength"].ToString();
int sEcho = int.Parse(Request.Form["sEcho"].Trim());
DataSet ds = BLL.UserBll.getUser(iDisplayStart, iDisplayLength);
JsonHelper jsonHelp = new JsonHelper();
jsonHelp._sEcho = sEcho;
jsonHelp._iTotalRecords = ds.Tables[0].Rows.Count;
jsonHelp._iTotalDisplayRecords = ds.Tables[0].Rows.Count - 2;
if (ds != null)
{
DataTable DTable = ds.Tables[0];
for (int i = 0; i < DTable.Rows.Count; i++)
{
// 循环生成JSON代码 ==
foreach (DataRow item in DTable.Rows)
{
int cc = 0;
jsonHelp.AddItem(item[i].ToString());
cc++;
}
jsonHelp.ItemOk();
}
}
//Response.ContentType = "text/html";
Response.Write(jsonHelp.ToString();); // 输出JSON代码
}
}
[/code]
This discussion has been closed.