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

[Solved] problem with selectedIndex in bindTo combobox in mvc3 grid

3 Answers 77 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Sugar
Top achievements
Rank 1
Sugar asked on 12 Oct 2011, 08:10 PM
Hi all,

I want to have some comboboxes in my grid, so i'm using the code:

columns.Bound(x=> x.ID).Title("Status").ClientTemplate(
                                                                                Html.Telerik().ComboBox()
                                                                                .Name("XX")
                                                                                .Enable(false)
                                                                                .BindTo(new SelectList(Config.X, "xID", "Name", "<#=ID#>"))
                                                                                //.AutoFill(true)
                                                                                .ToHtmlString()
                                                                                )

But the selected Index is not coming through, it's also not in the EditorTemplate:

@(Html.Telerik().ComboBox()
          .BindTo(new SelectList(Config.X, "xID", "Name", "<#=ID#>"))
      .Name("XX")
      .AutoFill(true)
      .Filterable(filtering => filtering.FilterMode(AutoCompleteFilterMode.StartsWith))
)

Help! thanks :)

3 Answers, 1 is accepted

Sort by
0
Sugar
Top achievements
Rank 1
answered on 13 Oct 2011, 05:23 PM
Well,

I've added a js function binding to onEdit:
 if (e.mode == 'edit') {
            var dataItem = e.dataItem;
            var cComboBox = $('#ddlInOutStatuses').data('tComboBox');
            cComboBox.selectedValue = dataItem.StatusID;
        }

the selectedText however is not updated, even though when I use the dropdown I can see my correctly selectedIndex highlighted.

Any help would be greatly appreciated. I would like to avoid having to use the above script at all possible.I guess the main question is a syntax one for ClientTemplates, and binding to a selectedIndex using BindTo().

For example:

.BindTo(new SelectList(Config.GetEm(), "Id", "Description", 35)) - This works, but I need to have the ID that is passed into the data grid passed into this bind to.

Thanks :)
0
Sugar
Top achievements
Rank 1
answered on 13 Oct 2011, 09:15 PM
Maybe this is a bug because I can't get the comboBoxes in the client template to bind using Ajax (the method does not fire)

when inside a grid that is also bound by Ajax.

I have also artificially set the selectedIndex, and that is getting passed with a value of 0 to the editor template.

Definitely looks like a bug, because:
.ClientTemplate("<input type='text' name='txtStatus' value='<#= ID #>' />")

brings over the client binding data OK
0
Sugar
Top achievements
Rank 1
answered on 14 Oct 2011, 01:55 PM
Also,

If I try and do a Html.Telerik().ComboBoxFor<T>, the T is the model of the View (strongly typed view) and not the T type that is added there.

No matter whether I qualify the T explicitly or not.

Some help on this would be greatly appreciated.

Thanks!
Tags
Grid
Asked by
Sugar
Top achievements
Rank 1
Answers by
Sugar
Top achievements
Rank 1
Share this question
or