在我的MVC應用程序中,我使用jqGrid在整個應用程序中顯示記錄。要加載網格,我遍歷從存儲過程中檢索的數據集對象以構建結構化對象列表。見下面我可以從DataTable直接綁定jqGrid源代碼,就像在asp數據網格控件中做的一樣
List<CustomerOrders> ResultRows = new List<CustomerOrders>();
JQGridResult Result = new JQGridResult()
{
page = 1,
records = 0,
orders = new List<CustomerOrders>(),
total = 1
};
DataSet SearchResult = DB.ExecuteDataset("ConnectionString", "pc_ADMDbdPOXOrderStatsDetails",
new SqlParameter("@AggregateFlag", 1),
new SqlParameter("@CustomerID", SessionManager.GetSession().CustomerID),
new SqlParameter("@QualifierType", QualifierType),
new SqlParameter("@FromDate", FromDate),
new SqlParameter("@ToDate", ToDate),
new SqlParameter("@RoleList", null),// remove SqlParameter; when SP is modified to remove this param.
new SqlParameter("@BranchList", BranchList == "" ? null : BranchList),
new SqlParameter("@Display", null));
//Export to Excel
Common.SetSession(SearchResult, null, "POXOrderStatistics");
DataRowCollection DataRows = SearchResult.Tables[0].Rows;
foreach (DataRow item in DataRows)
{
ResultRows.Add(new CustomerOrders()
{
CustomerID = Convert.ToInt32(item["CustomerID"]),
CompanyName = Convert.ToString(item["CompanyName"]),
ReadingCount = Convert.ToInt32(item["ReadingCount"]),
DateRange = string.Format("From: {0} To: {1}", FromDate, ToDate)
});
}
Result.orders = ResultRows;
Result.records = ResultRows.Count;
return Json(Result, JsonRequestBehavior.AllowGet);
現在我想要的代碼是不消除這種遍歷所有數據集&需要找出辦法讓我可以直接返回我的數據集/ DataTable對象的記錄源的jqGrid。與我們如何將DataSet對象綁定到asp網格控件有些相似。 如果有人已經做了這樣的實施,請幫我在這種代碼消除
嗨奧列格請你可以查看我的[這個](http://stackoverflow.com/questions/21191473/how-to-assign-option-string-containing-br-to-editions-value-attribute-of- jqgri)quetion並建議我解決它。這需要緊急解決。 – Shaggy