lundi 6 juillet 2015

Add parameters to WebGrid column headers

I have a WebGrid implemented with my own paging, and I am trying to add an additional parameter to the column headers link. The problem I am having is that when a column is sorted I lose selected values from other form input elements (in my case a PageSize dropdown)

Here is how my WebGrid is initialised.

Dim grid = New WebGrid(Nothing,
    sortFieldName:="SortBy",
    sortDirectionFieldName:="SortDirection",
    canPage:=False,
    rowsPerPage:=Model.SortData.PageSize)

grid.Bind(Model.ReqPointAccountCodes, autoSortAndPage:=False, rowCount:=Model.SearchCriteria.TotalRecordCount.Value)

Dim colDefinitions = New List(Of WebGridColumn)({
        grid.Column("ReqPoint", header:="Requisition point"),
        grid.Column("ReqPointName", header:="Name")})

The grid is rendered using:

<%: grid.GetHtml(columns:=grid.Columns(colDefinitions.ToArray()))%>

I don't want to resort to a javascript hack to dynamically update the links. Is there any way to add params to headers using only WebGrid?

Thanks, Richard

Aucun commentaire:

Enregistrer un commentaire