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

[Solved] Using Telerik Mvc Slider in DataTemplate of Telerik Mvc Grid

1 Answer 49 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
stewart
Top achievements
Rank 1
stewart asked on 23 Jul 2011, 10:52 PM
Would like to be able to have a grid with a column of sliders:
<% Html.Telerik().Grid<LineItem>(lineItems)
 .Name("Grid")
 .Columns(columns =>
         {
            columns.Template(item =>
               { // checkbox markup }).Title("");
            columns.Bound(c => c.Name);
            columns.Template(item => Html.Telerik().SliderFor(o => item.AveragePrice).Min(item.MinimumPrice)
    .Max(item.MaximumPrice)).Title("Your price");
          })
  .Groupable(builder => builder.Groups(factory => factory.Add(o => o.LineItemCategory.Name)).Visible(false))
  .BindTo(lineItems)
  .Render();
%>

This code results in the first row containing a Telerik Slider but every row after that containing a default html slider with no formatting.

After stepping through the server side .aspx generation it appears that columns.Template is only being called once which is expected but leaving me a bit puzzled on how to do this.  

Any help would be greatly appreciated!

Attached is a screenshot of the grid I am seeing.

1 Answer, 1 is accepted

Sort by
0
stewart
Top achievements
Rank 1
answered on 27 Jul 2011, 02:37 AM
Fix is to add a unique name to each slider:

Html.Telerik().SliderFor(o => item.AveragePrice).Min(item.MinimumPrice)
    .Max(item.MaximumPrice).Name(someUniqueName)

Tags
General Discussions
Asked by
stewart
Top achievements
Rank 1
Answers by
stewart
Top achievements
Rank 1
Share this question
or