Telerik UI for ASP.NET MVC
I have wrongly assumed that the ListBox would work the same or similar to the grid.
I have created and populated a ListBox
cshtml..
@(Html.Kendo().ListBox()
.Name(componentName: "lstRewindRolls")
.Selectable(ListBoxSelectable.Single)
.HtmlAttributes(new { tabindex = -1, @class = "k-listbox", style = "background-color:black; color:white; height:450px" })
.DataValueField("DoffID")
.DataTextField("RollID")
.DataSource(dataSource => dataSource
.Read(read => read.Action(actionName: "GetRolls", controllerName: "Rewind").Data("{ DispositionCode: 'R' }"))
)
.Events(events=> events.Change("RewindRollSelected"))
)
controller...
public
JsonResult GetRolls(
string
DispositionCode)
{
try
{
var result = db.tblRolls.Where(r => r.strDispositionCode == DispositionCode && r.dtmInventoryRemoved ==
null
)
.Join(db.tblProductSKUs, p => p.lngProductSKUID, q => q.lngProductSKUID, (r, q) =>
new
{ r, q })
.Join(db.tblProducts, s => s.q.lngProductID, t => t.lngProductID, (s, t) =>
new
{ s, t })
.Select(o =>
new
{
DoffID = o.s.r.lngDoffID.ToString(),
LaneID = o.s.r.strLaneID,
RollID = o.s.r.lngDoffID.ToString() + o.s.r.strLaneID
}).OrderBy(t =>
new
{ t.DoffID, t.LaneID }).ToList();
;
return
Json(result, JsonRequestBehavior.AllowGet);
}
catch
(Exception ex)
{
...
}
When the page loads the ListBox is populated as expected.
Once I have processed an item in the list, if appropriate (the disposition changed) I want it removed from the list.
I thought I could simply do a dataSource.read()
var lstBox = $("#lstRewindRolls").data("kendoListBox");
lstBox.dataSource.read();
I also tried
var lstBox = $("#lstRewindRolls").data("kendoListBox");
lstBox.dataSource.read({ DispositionCode: 'R' });
I cannot seem to get it to work.
Please help.