Hello I am using jqgrid to load some data in a .net MVC 3.0 C# application.
There is a materials grid that needs to be loaded in about 6 different places. They are all the same. The grid is listing the pricing and details of about 8700 items.
The issue that I have is that two of the columns "cost" and "price" have calculations that are performed from the database. These two columns make the grid load extremely slow.
The material testing list we were working with had about 730 items initially. The first time without some sort of optimiztion the grid would take about 1min 30 secs to load completely. After the changes this dropped to about 4 seconds which is acceptable.
We are now working with the real list that will be used for the materials and this list contains 8500+ items. After the innitial load it is talking about 2 mins by watch to load the 8500 items.
This will really not be acceptable and so I am thinking the best solution is to have the search toolbar function or an external search be the one that loads the items but only the search result items.
So what I would like to see is that after the innitial page loads the grid is empty and only gets filled after a search is done and only shows the search results.
If possible would be the best to be able to do this with the search toolbar feature. This is already working properly but after the innitial long load.
Any suggestions would be very welcomed. I am not the original programmer just trying to get some information so I do not have to pay my dev for google searches if possible.
Thank you for your time, if an example of the current code is needed please let me know if it would help or if you could just provide some sample code if what I need is possible,
Serer side code:
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 grid code`jQuery(document).ready(function () { var grid = jQuery("#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: "" });`