Hello,
I'm trying to load some combobox values from the controller... but when I open the dropdown I got 2 items undefined (even if in the controller for test I return an empty collection)...what am I doing wrong?
Thanks
View :
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<KendoUIMvcApplication1.TestObj>" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
PROVA HEADER
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<%
Html.Kendo().ComboBox()
.Name("comboBox")
.DataTextField("Description")
.DataValueField("Value")
.AutoBind(false)
.Placeholder("Selezionare un oggetto")
.DataSource(ds =>
{
// ds.Ajax()
// .ServeOperation(false)
ds.Read(read =>
{
read.Action("GetCombo", "TestIDEA");
});
})
.Events(events =>
{
events.Change("Test");
})
.Render();
%>
<script>
function Test(e) {
alert('changed');
}
</script>
</asp:Content>
Controller :
public ActionResult GetCombo([DataSourceRequest] DataSourceRequest request)
{
List<TestObj> myList = new List<TestObj>();
//myList.Add(new TestObj { Value = "1", Description = "A1" });
//myList.Add(new TestObj { Value = "2", Description = "A2" });
return Json(myList, "text/html", Encoding.UTF8, JsonRequestBehavior.AllowGet);
}
Thanks
I'm trying to load some combobox values from the controller... but when I open the dropdown I got 2 items undefined (even if in the controller for test I return an empty collection)...what am I doing wrong?
Thanks
View :
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<KendoUIMvcApplication1.TestObj>" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
PROVA HEADER
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<%
Html.Kendo().ComboBox()
.Name("comboBox")
.DataTextField("Description")
.DataValueField("Value")
.AutoBind(false)
.Placeholder("Selezionare un oggetto")
.DataSource(ds =>
{
// ds.Ajax()
// .ServeOperation(false)
ds.Read(read =>
{
read.Action("GetCombo", "TestIDEA");
});
})
.Events(events =>
{
events.Change("Test");
})
.Render();
%>
<script>
function Test(e) {
alert('changed');
}
</script>
</asp:Content>
Controller :
public ActionResult GetCombo([DataSourceRequest] DataSourceRequest request)
{
List<TestObj> myList = new List<TestObj>();
//myList.Add(new TestObj { Value = "1", Description = "A1" });
//myList.Add(new TestObj { Value = "2", Description = "A2" });
return Json(myList, "text/html", Encoding.UTF8, JsonRequestBehavior.AllowGet);
}
Thanks