我的 Jqgrid 在 500 行后冻结,页面被阻塞,如果行超过 1000 或 1500,那么一个浏览器警报会出现并说“执行脚本的时间很长......你想停止还是继续......”我在无人区你能检查我的代码并建议我吗..我做错了什么吗?
one more issue is Why my loading GIF image and page stuck until all rows loaded?
$(document).ready(function ()
{
GetTrackOrdersData();
});
var searchFilter = {};
searchFilter.REFERENCE = "%";
searchFilter.INVOICENOR = "";
searchFilter.PRODNAME = "ALL";
searchFilter.ORDSTATUS = "WIP";
------etc ------
function GetTrackOrdersData()
{
var param = JSON.stringify(
{
'searchFilter': searchFilter
}); //This function is from JSon2.js
$.ajax(
{
type: "POST",
url: "TrackOrdersNew.aspx/GetTrackOrdersData",
data: param,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (mydata)
{debugger;
var mydata = $.parseJSON(mydata.d);
if (mydata != null && mydata.length == 0)
{
$('#divgrid').hide();
$('#gbox_list1').hide();
$("#jqgridWrapperdiv").hide();
alert('No Records');
}
else if(mydata != null)
{
var i = 0;
for (i; i <= mydata.length; i++)
{
jQuery("#list1").jqGrid('addRowData', i + 1, mydata[i]);
}
if (i > 0)
{
$('.ui-jqgrid-title').text('Track Orders (' + (i - 1) + ')');
}
$("#jqgridWrapperdiv").hide();
$('#divgrid').show();
}
},
error: function (mydata)
{
alert("Some thing went wrong because of network. Please reload the page. Code:100T"+mydata.responseText);
$('#divgrid').hide();
},
complete: function ()
{
$("#jqgridWrapperdiv").hide();
}
});
}
function bindGrid()
{
jQuery("#list1").jqGrid(
{
datatype: "local",
colNames: ['Customer', 'Delivery', 'TrackNo','Ref', 'JobNo', 'Type', 'Product', 'Status',
'EntryDate', 'Scheduled', 'Invoiced'
],
colModel: [
{
name: 'CUOH_CUST_CD',
index: 'CUOH_CUST_CD',
width: 100,
classes: 'pointer'
},
{
name: 'CUOA_DEL_CUST_CD',
index: 'CUOA_DEL_CUST_CD',
width: 69,
classes: 'pointer'
},
{
name: 'CUOH_TRAK_NO',
index: 'CUOH_TRAK_NO',
width: 70,
classes: 'pointer'
},
{
name: 'CUOH_SOURCE_REF',
index: 'CUOH_SOURCE_REF',
width: 70,
classes: 'pointer'
},
{
name: 'CUOH_JOB_NO',
index: 'CUOH_JOB_NO',
width: 60,
classes: 'pointer'
},
{
name: 'CUOH_ORDER_TYPE',
index: 'CUOH_ORDER_TYPE',
width: 65,
classes: 'pointer'
},
{
name: 'CUOL_DESCR_LOC',
index: 'CUOL_DESCR_LOC',
width: 155,
classes: 'pointer'
},
{
name: 'Status',
index: 'Status',
width: 100,
classes: 'pointer',
cellattr: function (rowId, value)
{
// additional parameter of cellattr: rawObject, cm, rdata are optional
if (value.indexOf("ompleted")!=-1)
{
return ' class="bcolor"';
}
}
},
{
name: 'CUOH_ENTRY_DATE_TIME',
index: 'CUOH_ENTRY_DATE_TIME',
formatter: 'date',
formatoptions:
{
srcformat: 'd/m/Y',
newformat: 'd/m/Y'
},
width: 77,
classes: 'pointer'
},
{
name: 'CUOH_SCHEDULE_DATE',
index: 'CUOH_SCHEDULE_DATE',
formatter: 'date',
formatoptions:
{
srcformat: 'd/m/Y',
newformat: 'd/m/Y'
},
width: 84,
classes: 'pointer'
},
{
name: 'CUOH_INVOICE_DATE_TIME',
index: 'CUOH_INVOICE_DATE_TIME',
formatter: 'date',
formatoptions:
{
srcformat: 'd/m/Y',
newformat: 'd/m/Y'
},
width: 72,
classes: 'pointer'
}],
//multiselect: true,
//rowList: [10, 20, 30, 40],
//pager: jQuery('#pager1'),
//rowList: [], // disable page size dropdown
//pgbuttons: false, // disable page control like next, back button
//pgtext: null, // disable pager text like 'Page 0 of 10'
//viewrecords: true, // disable current view record text like 'View 1-10 of 100'
rowNum: 10000,
sortorder: "asc",
caption: "Track Orders",
gridview: true,
//shrinkToFit: true,
loadui:"block",
loadonce: true,
rownumbers: true, //Displays Row number Column
onSelectRow: function (rowId)//ondblClickRow
{
var rowData = jQuery(this).getRowData(rowId);
var trackingNo = rowData['CUOH_TRAK_NO'];
RowClicked(trackingNo);
}
});
}
升C:
[WebMethod(EnableSession = true)]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public static string GetTrackOrdersData(TrackOrdersFilterData searchFilter)
{
if (HttpContext.Current.Session["LoginName"] == null)
{
HttpContext.Current.Response.Redirect("~/Login.aspx");
}
string val = string.Empty;
DataSet ds = GetTrackOrders(searchFilter);
if (ds.Tables.Count > 0)
{
val = DataTableToJSON(ds.Tables[0]);
}
return val;
}