こんにちは私はjqgridを使って.net MVC 3.0 C#アプリケーションのデータを読み込みます。jqgridツールバーの検索または外部検索機能
約6つの異なる場所にロードする必要があるマテリアルグリッドがあります。彼らはすべて同じです。グリッドには約8700アイテムの価格と詳細が掲載されています。
問題は、「コスト」と「価格」の2つの列にデータベースから実行される計算があることです。これらの2つの列は、グリッドの負荷を極端に遅くします。
私たちが作業していた材料テストリストには、最初に約730個のアイテムがありました。いくつかの種類の最適化がない最初の場合、グリッドは完全にロードするのに約1分30秒かかります。変更後、これは許容可能な約4秒に低下した。
これで、材料に使用される実際のリストが作成されました。このリストには8500以上のアイテムが含まれています。最初のロードの後、それは8500アイテムをロードする時計で約2分を話している。
これは実際には受け入れられないので、検索ツールバー機能や外部検索はアイテムを読み込む検索結果アイテムのみにすることをお勧めします。
私が見たいのは、最初のページが読み込まれた後、グリッドが空であり、検索が完了して検索結果のみが表示されることです。
可能であれば、検索ツールバーの機能でこれを行うことができます。これは既に正常に動作していますが、長い初期の負荷の後です。
非常に歓迎される提案です。私は元のプログラマーではないので、できるだけGoogle検索のために私のdevを支払う必要はありませんいくつかの情報を取得しようとしています。現在のコードの例が必要な場合
はSerer側のコード、私は必要なものが可能であるならば、あなたはいくつかのサンプルコードを提供することができれば、私はそれが役立つかどうかを知るか、聞かせてください、お時間をいただき、ありがとうございます:
public ActionResult EstimateMaterialAddGridData(string sidx, string sord, int page, int rows)
{
IQueryable<Material> mats;
mats = Material.Find(x => x.OwnerId == UserAccount.GetOwnerId && x.isDeletedFromCatalog == false).AsQueryable();
int pageIndex = page - 1;
int pageSize = rows;
int totalRecords = mats.Count();
int totalPages = (int)Math.Ceiling((float)totalRecords/(float)pageSize);
var jsonData = new
{
total = totalPages,
page = page,
records = totalRecords,
rows = (
from sub in mats
select new
{
i = sub.Id,
cell = new string[] {
sub.Id.ToString(),
sub.Id.ToString(),
sub.Id.ToString(),
sub.ProductCode,
sub.Description,
sub.Units,
sub.Categories,
sub.UnitCost.ToString(),
sub.Price.ToString()
}
}
).ToArray()
};
return Json(jsonData);
}
JSグリッドcode`jQuery(ドキュメント).ready(関数(){ VARグリッド
= jQueryの( "#1 MGRID");grid.jqGrid({
url: '/Material/EstimateMaterialAddGridData',
datatype: 'json',
mtype: 'POST',
colNames: ['Id', '','View/Edit', 'Product Code', 'Description', 'Units', 'Categories', 'Cost', 'Price'],
colModel: [
{ name: 'Id', index: 'Id', key: true, hidden: true, editrules: { edithidden: true} },
{ name: 'Add', index: 'Add', sortable: false, width: 50,search:false, resizable: false, editable: false, align: 'center', formatter: formatLink, classes: 'not-editable-cell' },
{ name: 'Open', index: 'Open', sortable: false, width: 90,search:false, resizable: false, editable: false, align: 'center', formatter: formatLinkNew, classes: 'not-editable-cell' },
{ name: 'ProductCode', index: 'ProductCode', sorttype: 'text',search:true, width: 100, resizable: false },
{ name: 'Description', index: 'Description', sorttype: 'text',search:true, width: 275, resizable: false },
{ name: 'Units', index: 'Units', sorttype: 'text', width: 75,search:true, resizable: false },
{ name: 'Categories', index: 'Categories', sorttype: 'text',search:true, width: 300, resizable: false, editable: false, },
{ name: 'UnitCost', index: 'UnitCost', sorttype: 'float', width: 75,search:true, align: 'right', resizable: false, editable: false, formatter: 'currency' },
{ name: 'Price', index: 'Price', sorttype: 'float', width: 75, search:true,align: 'right', resizable: false, editable: false, formatter: 'currency' },
],
pager: '#mpager',
height: '100%',
rowNum: 10,
rowList: [10, 20, 50, 100],
sortname: 'Id',
sortorder: 'desc',
sortable: true,
loadonce: true,
ignoreCase: true,
viewrecords: true,
caption: 'Material',
cellEdit: false,
hidegrid: false,
viewrecords: true,
});
grid.jqGrid('navGrid', '#mpager',
{ resize: false, add: false, del: false, search: true, refresh: true, edit: false, alerttext: 'Please select an material' }
).jqGrid('navButtonAdd', '#mpager',
{ title: "Create New Material Catalouge", buttonicon: "ui-icon-plus", onClickButton: newMaterial, position: "First", caption: "" });`
現在、jqGridを使用するコードを含めることができますか?列 "コスト"と "価格"の実装に関する詳細情報を含めることができますか。なぜ列に問題があるのか理解できません。列の値を生成するSELECTが遅すぎますか? – Oleg