ListView sort field

2 posts, 0 answers
  1. Ifte
    Ifte avatar
    2 posts
    Member since:
    Sep 2015

    Posted 21 Oct 2015 Link to this post

    I am new to Telerik MVC and JavaScript and jQuery.

    Here is my issue:

    I have two ListViews on my page:

      @(Html.Kendo().ListView(Model.ProfessionalsNotInGroup.Lines).Name("staffNotInGroupList").TagName("div").HtmlAttributes(new { style = "height: 580px; overflow: auto;" }).ClientTemplateId("groupTemplate").Selectable(selectable => selectable.Mode(ListViewSelectionMode.Multiple)).Navigatable().DataSource(ds => ds .Sort(sort =>{ sort.Add(f => f.Proname);}).Model(m =>{ m.Id(f => f.Userguid); m.Field(f => f.Proname);})).Deferred())

     

    AND

      @(Html.Kendo().ListView(Model.ProfessionalsInGroup.Lines).Name("staffInGroupList").TagName("div").HtmlAttributes(new { style = "height: 580px; overflow: auto;" }).ClientTemplateId("groupTemplate").Selectable(selectable => selectable.Mode(ListViewSelectionMode.Multiple)).Navigatable().DataSource(ds => ds .Sort(sort =>{ sort.Add(f => f.Proname);}).Model(m =>{ m.Id(f => f.Userguid); m.Field(f => f.Proname);})).Deferred())

     

    The template for the ListViews:

     <script type="text/x-kendo-tmpl" id="groupTemplate"><div class="staff"><span>#: Proname#</span></div>

    I have a button that moves items from one ListView to Another:

    function addStaffToGroup(e) {var lvStaffNotInGroupList = $("#staffNotInGroupList").data("kendoListView");var StaffSelections = lvStaffNotInGroupList.select();var lvStaffInGroupList = $("#staffInGroupList").data("kendoListView");for (i = 0; i < StaffSelections.length; i++){ lvStaffInGroupList.dataSource.add(lvStaffNotInGroupList.dataItem(StaffSelections[i])); lvStaffInGroupList.refresh(); lvStaffNotInGroupList.dataSource.remove(lvStaffNotInGroupList.dataItem(StaffSelections[i])); lvStaffNotInGroupList.refresh();}}

    The problem being whenever I remove or add items to the ListViews and call refresh() the ListViews are not being sorted alphabetically.​​​

    How do I achieve this please?

    Thank you.​

  2. Ifte
    Ifte avatar
    2 posts
    Member since:
    Sep 2015

    Posted 21 Oct 2015 in reply to Ifte Link to this post

    I fixed it by adding:

                    .DataSource(ds => ds
                        .ServerOperation(false)

    And now its is sorted on client side! Thank you for your time.​

  3. UI for ASP.NET MVC is VS 2017 Ready
Back to Top