Hello,
I have a model with a few lists. I am trying to use a
shared datasource to populate a dropdownlist for each of these lists but I am
having trouble with how to refer to a specific subobject within the object that
is returned from the controller. I’m
sure that this has been done before… I’m just having trouble finding an
example.
My model looks
like this:
public class BillModel : DocumentBaseModel
{
…
public List<HistoryModel> History { get; set; }
public List<AmendmentModel> Amendments { get; set; }
public List<OtherDocModel> OtherDocs { get; set; }
public List<PreviousVersionModel> PreviousVersions { get; set; }
}
My controller
returns the BillModel
My view has a
grid that accesses a ClientTemplate that has three ddls and my shared
datasource.
@(Html.Kendo().DataSource<BillModel>()
.Name("myDataSource")
.Custom(dataSource =>
{
dataSource
.Type("json")
.Transport(transport =>
{
transport.Read(read =>
{
read.Action("GetBill", "Bills", new { billNo = "#=Id#"});
});
});
})
)
@(Html.Kendo().DropDownList()
.Name("amendments")
.DataTextField("Name")
.DataValueField("LFID")
.DataSource("myDataSource")
.HtmlAttributes(new { style = "width: 100%" })
.ToClientTemplate()
)
@(Html.Kendo().DropDownList()
.Name("others")
.DataTextField("Name")
.DataValueField("LFID")
.DataSource("myDataSource")
.HtmlAttributes(new { style = "width: 100%" })
.ToClientTemplate()
)
@(Html.Kendo().DropDownList()
.Name("previous")
.DataTextField("Name")
.DataValueField("LFID")
.DataSource("myDataSource")
.HtmlAttributes(new { style = "width: 100%" })
.ToClientTemplate()
)
How do I get each ddl to use
their list from the datasource? I
thought perhaps I could use dot notation and write .DataTextField(“Amendments.Name”). It didn’t yell at me it just said undefined. I’m sure it must be something simple I just
can’t figure it out today.