I am using the Infragistics jQuery grid in my ASP .NET MVC application. My datasource is an ADO .NET Entity model referencing an SQL database. Here is the code from my controller to set up the grid and provide the datasource for it to pull from:
public ActionResult Index()
{
var model = new GridModel();
model.DataSourceUrl = Url.Action("GetInstrumentListData");
this.InitializeGridOptions(model);
return View(model);
}
public JsonResult GetInstrumentListData()
{
var model = new GridModel();
this.InitializeGridOptions(model);
model.DataSource = _db.InstrumentLists.OrderBy(x => x.Tag).AsQueryable<InstrumentList>();
return model.GetData();
}
private void InitializeGridOptions(GridModel model)
{
Code to create columns...
model.DefaultColumnWidth = "100px";
model.Width = "100%";
model.Height = "700px";
model.Features.Add(new GridFiltering());
var sort = new GridSorting();
sort.Mode = SortingMode.Multiple;
model.Features.Add(sort);
var paging = new GridPaging();
paging.PageSize = 30;
model.Features.Add(paging);
var selection = new GridSelection();
selection.Mode = SelectionMode.Row;
selection.MultipleSelection = true;
model.Features.Add(selection);
}
The grid was taking ages to display (25-40 secs) so I did some investigating and it's the model.GetData() call in GetInstrumentListData() that is taking up all the time. According to Intellisense, this function first performs data binding and generates the JsonResult object.
I thought that maybe since I was attempting to display a total of 1000 records (even though pagination is enabled and only displaying 30 each view) that maybe it was taking a while to convert those records into JSON, so I reduced the amount of records to 10 (from 1.2mb of JSON data to 12.5kb). There was no difference in time.
Here is the request tracing from Firebug.

Any ideas on what is happening?
EDIT: @allentranks' answer and @AlastairPitts comment made me realise that it is in fact the source I am getting my data from. The source isn't a table but a view, which was created by my DBA from a whole bunch of crazy joins. Turns out that it takes 13+ secs to run the query, so its no wonder its taking so long to load. Thanks for your help.