Hello all,
I've been playing around with the Kendo UI controls for a while now and for the most part, it's going great :) (otherwise I wouldn't be on the forums)
When working with the listview-control (configured in multi-select-mode) I can't get the list of selected items.
Code:
Controller:
To check if I actually selected something, I added an event (the change event "onSelectObject):
This works. Meaning that when I select items in my listview, the event is fired and I see the alert-message with the correct length and list of selected items.
Now my question is, when I click the "search" button in the form above, how do I get the list of selected items in my controller?
I've been playing around with the Kendo UI controls for a while now and for the most part, it's going great :) (otherwise I wouldn't be on the forums)
When working with the listview-control (configured in multi-select-mode) I can't get the list of selected items.
Code:
01.@using (Html.BeginForm("MyMethod", "MyController",Model)) 02.{ 03. @(Html.Kendo().ListView<List<MyObject>>() 04. .Name("ListOfObjects") 05. .DataSource(datasource => datasource.Read(read => read.Action("GetMyListOfObjects", "MyController"))) 06. .Selectable(select => select.Mode(ListViewSelectionMode.Multiple)) 07. .ClientTemplateId("selectedItems") 08. .TagName("div") 09. .Events(e => e.Change("onSelectObject")) 10. ) 11.<input type="submit" class="submit" value="Search" /> 12.}1.public ActionResult GetMyListOfObjects([DataSourceRequest]DataSourceRequest request) 2.{ 3. return Json(MyService.GetMyListOfObjects().ToDataSourceResult(request)); 4.}To check if I actually selected something, I added an event (the change event "onSelectObject):
function onSelectObject(e) { var selected = $.map(this.select(), function (item) { return $(item).text(); }); alert("Selected: " + selected.length + " item(s), [" + selected.join(", ") + "]"); return selected; }This works. Meaning that when I select items in my listview, the event is fired and I see the alert-message with the correct length and list of selected items.
Now my question is, when I click the "search" button in the form above, how do I get the list of selected items in my controller?
1.public ActionResult MyMethod(List<MyObject> selectedObjects) 2.{ 3. //...selectedObjects is always null 4. return View(); 5.}