This question is locked. New answers and comments are not allowed.
I often need to create my own custom commands for a given grid outside the scope of the built-in CRUD commands. For instance, I need to have a disable button for each row in a grid, and I am sort of stumped about how to maintain the grid state when doing so:
The problem with that template is it loses any order-by or sort-by information that I might have associated with the grid. I have noticed this information is accessible from the Edit command, and I see that it is appended in the query string to the action links created (for Editing).
The GridCommand command parameter contains all the information I need.
<% Html.Telerik().Grid(Model.Clients) .Name("Grid") .DataKeys(k => k.Add(o => o.Id)) .PrefixUrlParameters(false) .Editable( e => e.Mode(GridEditMode.PopUp)) .Sortable() .ToolBar(commands => commands.Insert().ButtonType(GridButtonType.ImageAndText)) .DataBinding( b => b.Server() .Select("Index", "Client") .Update("Update", "Client") .Insert("Insert", "Client") ) .Columns(columns => { columns.Bound(o => o.Id).Visible(false).ReadOnly(true); columns.Bound(o => o.IP).Width(150); columns.Bound(o => o.TerminalNumber).Visible(true).Title("Terminal").Width(50); columns.Bound(o => o.Description).Width(300); columns.Bound(o => o.Disabled).Width(50); columns.Bound(o => o.Terminals).Visible(false).Sortable(false); columns.Template(c =>{ %> <% using (Html.BeginForm("Disable", "Client", new { id = c.Id }, FormMethod.Post, new { @class = "t-grid-actions" })) { %> <button class="t-grid-action t-button t-state-default" type="submit">Disable</button> <% } %> <% }).Width(50); columns.Command(s => { s.Edit(); }).Width(100); }).Render(); %>The problem with that template is it loses any order-by or sort-by information that I might have associated with the grid. I have noticed this information is accessible from the Edit command, and I see that it is appended in the query string to the action links created (for Editing).
[HttpPost]public ActionResult Update(EditableClientGridItem viewModel, GridCommand command, string mode, int? id)The GridCommand command parameter contains all the information I need.