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

ListView sort field

1 Answer 244 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Ifte
Top achievements
Rank 1
Ifte asked on 21 Oct 2015, 11:16 AM

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.​

1 Answer, 1 is accepted

Sort by
0
Ifte
Top achievements
Rank 1
answered on 21 Oct 2015, 04:26 PM

I fixed it by adding:

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

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

Tags
ListView
Asked by
Ifte
Top achievements
Rank 1
Answers by
Ifte
Top achievements
Rank 1
Share this question
or