This is a migrated thread and some comments may be shown as answers.

[Solved] New Operation Mode Not Respecting Client Only Paging and Sorting

1 Answer 49 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
LarryJ
Top achievements
Rank 1
LarryJ asked on 14 Jul 2011, 01:51 AM
I have been looking forward to the OperationMode as I would love to have a way to persist grouping state, etc.

I have two questions...
#1 - I am working server side for the initial binding and we have checkboxes. This includes client and server templates. I have been looking for a way to capture the state of the grid when calling the controller via Ajax? How can I do that?

#2 - If I go all server side, how can I capture the state of the grid so I can persist via my own session the sorting, page, grouping, etc? easily and then assign them?

#3 - In order to use OperationMode, do I have to be all Ajax? Or can I mix the server binding and then Ajax (this does not work in my testing so far)

Below is my grid definition...
<%
    int[] checkedRecords = (int[])ViewData["checkedRecords"];
    Html.Telerik().Grid(Model.AdminSongQueue)
        .Name("AdminViewQueueGrid")
        .DataBinding(
            dataBinding => dataBinding.Ajax()
                .OperationMode(GridOperationMode.Client)
                .Select("_Index", "Admin")
            )
        .DataKeys(k => k.Add(o => o.ProviderTrackId))
        .Columns(columns =>
        {
            columns.Template(o =>
            {
                %>
                    <input name="adminFormViewModel.SelectedRecords" id="adminFormViewModel_SelectedRecords" type="checkbox" value="<%= o.ProviderTrackId %>" />
                <%
            }).Title(strings.ID_25).Width(25).HtmlAttributes(new { style = "text-align:center" })
            .ClientTemplate("<input type='checkbox' name='adminFormViewModel.SelectedRecords' id='adminFormViewModel_SelectedRecords' value='<#= ProviderTrackId #>' />")
                   .Title(strings.ID_25)
                   .Width(25);
            columns.Bound(o => o.ProviderTrackId).Title(strings.ID_18).Width(30).HtmlAttributes(new { style = "font-weight:normal" });
            columns.Bound(o => o.track_title).Title(strings.ID_19).HtmlAttributes(new { style = "font-weight:normal" });
            columns.Bound(o => o.album_performers).Title(strings.ID_8).HtmlAttributes(new { style = "font-weight:normal" });
            columns.Bound(o => o.album_title).Title(strings.ID_42).HtmlAttributes(new { style = "font-weight:normal" });
            columns.Bound(o => o.full_name).Title(strings.ID_20).Width(150).HtmlAttributes(new { style = "font-weight:normal" });
            columns.Bound(o => o.workflow_status_descr).Width(50).Width(25).Title(strings.ID_22).HtmlAttributes(new { style = "font-weight:normal" });
            columns.Bound(o => o.deadline_date).Width(90).Format("{0:MM/dd/yyyy}").Title(strings.ID_28).HtmlAttributes(new { style = "font-weight:normal" });
        })
        .Sortable()
        .Groupable()
        .Filterable()
        .Resizable(resizing => resizing.Columns(true))
        .ClientEvents(events => events
                .OnRowSelect("GreenLight.AdminIndex.onRowSelect_AdminViewQueueGrid"))
        .Pageable(pager => pager.PageSize((int)ViewData["DisplayRecordCount"]).Style(GridPagerStyles.PageInput | GridPagerStyles.NextPrevious)
                                            .Position(GridPagerPosition.Both))
        .Selectable()
        .Render();
%>

1 Answer, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 14 Jul 2011, 10:15 AM
Hi Larryj,

Straight to your questions:

1. You may use the GridCommand to get current state (such as sort/group/filter expression and paging info)  during ajax select operation. For example:

@(Html.Telerik().Grid<GridGroupBySorted.Models.Product>()
                  .Name("Products")
                  .Sortable()
                  .Pageable()
                  .Groupable()
                  .DataBinding(dataBinding => dataBinding.Ajax().Select("_Select", "Home"))                 
)

[GridAction]
public ActionResult _Select(GridCommand command)
{
    PersistPaging(command.Page, command.PageSize);
    PersistGroups(command.GroupDescriptors);
    //etc...
 
    return View(new GridModel(GetProducts));
}

2. When server binding is used, you may take the same approach as above. However, you should set GridName to the GridAction attribute:

[GridAction(GridName="Products")]       
public ActionResult Index(GridCommand command)
{
     //...
}
Then you may serialize the expression to a convenient format the pass them to the View.

You may find examples of how to set initial sort expression and group expression in our online demos.

3. Indeed, Client operation mode is supported when Ajax binding is used and grid is initially populated from the server. Could you please elaborate more on which functionality is not working? A small runnable project which demonstrates the issue will be appreciated.
All the best,
Rosen
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
Grid
Asked by
LarryJ
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Share this question
or