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

Dropdownlist with Template info

1 Answer 164 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jon
Top achievements
Rank 1
Jon asked on 24 Apr 2017, 10:00 AM

Hi Guys,

i Have Problem with binding:

 

If I use this :

.BindTo((System.Collections.IEnumerable)ViewData["Analyten"])

it's work but if I us this:

.BindTo((SelectList)ViewData[ViewData.TemplateInfo.GetFullHtmlFieldName("") + "_Data"])

 

it does not work

Have you  any idea ?

 

Thank you

 

 

@model Delphi.ViewModels.VMAnalytCRUD
 
    @(
 Html.Kendo().DropDownListFor(m => m.AnalytId)
   .BindTo((System.Collections.IEnumerable)ViewData["Analyten"])
   // .BindTo((SelectList)ViewData[ViewData.TemplateInfo.GetFullHtmlFieldName("") + "_Data"])
    .DataTextField("AnalytName")
    .DataTextField("AnalytNummer")
    .DataValueField("AnalytId")
    .Template("#= AnalytNummer # - #= AnalytName #")
    .ValueTemplate("#= AnalytNummer # - #= AnalytName #")
    .Filter(FilterType.Contains)
    .AutoBind(false)
    )

1 Answer, 1 is accepted

Sort by
0
Accepted
Boyan Dimitrov
Telerik team
answered on 27 Apr 2017, 08:21 AM

Hello Murat,

The ViewData[ViewData.TemplateInfo.GetFullHtmlFieldName("") + "_Data"] is a generic way of getting data.  We use this approach for your foreign key column builder, but we store the data passed to foreign key builder in the view data so the editor template can get it.  The idea is to have one editor template  and be able to be used with more than one foreign key columns if needed. 

Regards,
Boyan Dimitrov
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Jon
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Share this question
or