Reputation: 11
I use jqgrid along with MVC3 in razor view engine, in jqgrid i have a dropdown column, i load the drop down like...
colModel: [{
name: 'Company',
index: 'Company',
width: 200,
editable: true,
edittype: 'select',
editoptions: {
dataUrl: '@Url.Action("PopulateDropdown", "ControllerName")'
}]
if i have 100 rows then controller action is called 100 times. Hence i used [OutputCache(Duration = 10, VaryByParam = "none", VaryByCustom = "Browser")]
in mycontroller.
please suggest any other idea so the drop down list item is fetched only once in the view and used the same to bind the rest.
Upvotes: 1
Views: 1489
Reputation: 221997
It you have 100 rows you don't need edit all the rows at once. Typically one uses either inline editing or form editing to edit one specified row. Then one save the row either by pressing Enter and by selecting another row. So only one row will be editing and all other rows will have just some text in the corresponding cell.
On the other side if you really need to cache the server response from '@Url.Action("PopulateDropdown", "ControllerName")'
you can set Cache-Control: max-age=60
directly in the HTTP header of the JSON response:
Response.CacheSetMaxAge (new TimeSpan (0, 1, 0)); // cache for 1 minute
Upvotes: 1