
@{
var grid = new Lib.Web.Mvc.JQuery.JqGrid.JqGridHelper<jqGrid.Models.ProductFormattedViewModel>("products",
caption: "Products",
...
);
}There two more options for controlling caption layer:- HiddenEnabled - This property defines whether the show/hide grid button is enabled.
- Hidden - This property defines whether the grid is initially hidden (no data is loaded, only caption layer is shown). This setting takes effect only if the Caption property is not empty string and HiddenEnabled is set to true.
Another new functionality supported by the helper is dynamic scrolling. This is supported through JqGridOptions.DynamicScrollingMode property, which can take one of the following values:
- JqGridDynamicScrollingModes.Disabled - Dynamic scrolling is disabled (this is default value).
- JqGridDynamicScrollingModes.HoldAllRows - Dynamic scrolling is enabled, the grid will hold all items requested.
- JqGridDynamicScrollingModes.HoldVisibleRows - Dynamic scrolling is enabled, the grid will hold only visible rows.
@{
var grid = new Lib.Web.Mvc.JQuery.JqGrid.JqGridHelper<jqGrid.Models.ProductFormattedViewModel>("products",
dynamicScrollingMode: Lib.Web.Mvc.JQuery.JqGrid.JqGridDynamicScrollingModes.HoldAllRows,
...
parametersNames: new Lib.Web.Mvc.JQuery.JqGrid.JqGridParametersNames() { PagesCount = "npage" },
...
);
}Now, we just need to modify controller action to support this parameter:[AcceptVerbs(HttpVerbs.Post)]The user can scroll through the rows and jqGrid will dynamically load all necessary data:
public ActionResult Products(JqGridRequest request, CustomSearchViewModel viewModel)
{
string filterExpression = String.Empty;
if (request.Searching)
{
//Generate filter expression
...
}
int totalRecordsCount = _productsRepository.GetCount(filterExpression);
JqGridResponse response = new JqGridResponse()
{
TotalPagesCount = (int)Math.Ceiling((float)totalRecordsCount / (float)request.RecordsCount),
PageIndex = request.PageIndex,
TotalRecordsCount = totalRecordsCount
};
response.Records.AddRange(from product in _productsRepository.FindRange(filterExpression, String.Format("{0} {1}", sortingName, request.SortingOrder), request.PageIndex * request.RecordsCount, (request.PagesCount.HasValue ? request.PagesCount.Value : 1) * request.RecordsCount)
select new JqGridRecord<ProductFormattedViewModel>(Convert.ToString(product.Id), new ProductFormattedViewModel(product)));
return new JqGridJsonResult() { Data= response };
}

@{
var grid = new Lib.Web.Mvc.JQuery.JqGrid.JqGridHelper<jqGrid.Models.ProductFormattedViewModel>("products",
groupingEnabled: true,
groupingView: new Lib.Web.Mvc.JQuery.JqGrid.JqGridGroupingView
{
Fields = new string[] { "Category" },
ColumnShow = new bool[] { false },
Summary = new bool[] { true },
DataSorted = true
},
...
);
}Setting DataSorted to true will cause jqGrid to add grouping column name (name not index) to sorting names (jqGrid requires data sorted by grouping column). There is also new DataAnnotation (JqGridColumnSummary)available which provides control ower group summary for the column.
Email