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

[Solved] DropDownList inside a Grid

2 Answers 93 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.
shed
Top achievements
Rank 1
shed asked on 12 Jul 2012, 09:39 AM
Hi,

I want to have a DropDownList inside a Grid (grid is not editable). I use Ajax binding and a ClientTemplate to show the dropdownlist. The DropDownList is shown but I'm not able to set the selected item and the events are not called.

@(Html.Telerik().Grid<Item>()
        .Name("MyGrid")
        .DataBinding(dataBinding => dataBinding.Ajax()
            .Select("LoadItems", "Actions"))
        .DataKeys(keys => keys.Add(m => m.Detail.ID))
 
        .Columns(columns =>
        {
            columns.Bound(m => m.Detail.Model).ReadOnly();
            columns.Bound(m => m.Detail.Nr).ReadOnly();
            columns.Bound(m => m.Detail.Name).ReadOnly();
            columns.Bound(m => m.Detail.IsUsedAs).ClientTemplate("" +
                Html.Telerik().DropDownList().Name("isusedas_<#=ID#>")
                                       .BindTo(new SelectList(ViewBag.IsUsedAsValues, "ID", "Value", "<#= Detail.IsUsedAs.ID #>"))
                                       .ClientEvents(e => e.OnChange("onChange").OnDataBound("onDataBound"))
                                       .HtmlAttributes(new { style = "width:93%;" })
                                       .Encode(false)).Encoded(false);
})
.Scrollable(c => c.Height("400px"))
.Sortable()
.Footer(false)
                                 
                                                                        )

My javascript functions onDataBound and OnChange are not called.  And <#= Detail.IsUsedAs.ID #> does not work to set the selected value.

Thanks in advance.
Best regards

2 Answers, 1 is accepted

Sort by
0
shed
Top achievements
Rank 1
answered on 12 Jul 2012, 01:47 PM
Maybe someone has another approach how I can solve this e.g. can i use Html.EditorFor inside a Grid-ClientTemplate?
I tried DropDownListFor but this doesn't work.

Best Regards
0
ishak külekci
Top achievements
Rank 1
answered on 05 Dec 2012, 02:34 PM
Hi,
You can use this solution: 
http://jagadeesh7n.wordpress.com/2011/07/22/adding-dropdownlist-to-telerik-mvc-grid/


Tags
Grid
Asked by
shed
Top achievements
Rank 1
Answers by
shed
Top achievements
Rank 1
ishak külekci
Top achievements
Rank 1
Share this question
or