what is the best way to optimize my json on an asp.net-mvc site
- by ooo
i am currently using jqgrid on an asp.net mvc site and we have a pretty slow network (internal application) and it seems to be taking the grid a long time to load (the issue is both network as well as parsing, rendering)
I am trying to determine how to minimized what i send over to the client to make it as fast as possible.
Here is a simplified view of my controller action to load data into the grid:
[AcceptVerbs(HttpVerbs.Get)]
public ActionResult GridData1(GridData args)
{
var paginatedData = applications.GridPaginate(args.page ?? 1, args.rows ?? 10,
i => new
{
i.Id,
Name = "<div class='showDescription' id= '" + i.id+ "'>" + i.Name + "</div>",
MyValue = GetImageUrl(_map, i.value, "star"),
ExternalId = string.Format("<a href=\"{0}\" target=\"_blank\">{1}</a>",
Url.Action("Link", "Order", new { id = i.id }), i.Id),
i.Target,
i.Owner,
EndDate = i.EndDate,
Updated = "<div class='showView' aitId= '" + i.AitId + "'>" + GetImage(i.EndDateColumn, "star") + "</div>",
})
return Json(paginatedData);
}
So i am building up a json data (i have about 200 records of the above) and sending it back to the GUI to put in the jqgrid.
The one thing i can thihk of is Repeated data. In some of the json fields i am appending HTML on top of the raw "data". This is the same HTML on every record. It seems like it would be more efficient if i could just send the data and "append" the HTML around it on the client side. Is this possible? Then i would just be sending the actual data over the wire and have the client side add on the rest of the HTML tags (the divs, etc) be put together.
Also, if there are any other suggestions on how i can minimize the size of my messages, that would be great. I guess at some point these solution will increase the client side load but it may be worth it to cut down on network traffic.