DropdownlistFor in Dynamic Grid

2 posts, 0 answers
  1. FposUser
    FposUser avatar
    13 posts
    Member since:
    May 2007

    Posted 20 Aug 2015 Link to this post

    I am creating a Dynamic Kendo Grid using GridBoundColumnBuilder().
    I loop through all of the controls on the previous page to create the grid. For example with myTextbox(), myCheckbox(), etc.
    These create columns in the grid. I have all of the columns creating and populating with data.
    My issue is with the Dropdownlist and the Multiselect list, they populate with data but do not display the correct data when the grid is created. The dropdown list displays the value, not the text of the previous control:
    1 = My 2 = Data
    The Dropdownlist will display 1 instead of My. And, the Multiselect only displays [object Object].
    When you click on either of the controls in the grid it switches to show the proper text, but loses it when you click off.
    Any ideas of what I am doing wrong?



    foreach (ControlBase control in flatColumns)
          GridBoundColumnBuilder<dynamic> thisColumn;
          if (control.Lookups != null && control.Lookups.Any())
                    if (!control.IsMultiSelect){
                         thisColumn = column.Bound(control.ControlType, control.ColumnName).Title(control.Description);
                            thisColumn = column.Bound(control.ControlType, control.ColumnName).Title(control.Description);
    Dropdown Template
    @(Html.Kendo().DropDownListFor(m => m).HtmlAttributes(new { @class = "form-control" })
        .BindTo((IEnumerable) ViewData[currentColumn + "List"])
    Multiselect Template
    @(Html.Kendo().MultiSelectFor(m => m)
                        .HtmlAttributes(new { @class = "form-control" })
                            .BindTo((IEnumerable)ViewData[currentColumn + "List"])

  2. Georgi Krustev
    Georgi Krustev avatar
    3724 posts

    Posted 24 Aug 2015 Link to this post

    Hello FposUser,

    My assumption is that widgets DataValueField/DataTextField options are not configured correctly (the "[object Object]" text leads me to this conclusion). If this is the case, then the widgets will not be able to display the correct selected value and text and will not be able to update the Grid edited model at all.

    Please verify that the DataValueField/DataTextField options points to the correct model fields (those that comes from the ViewData when widgets are bound).

    Georgi Krustev
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top