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

Radslider in radgrid

4 Answers 138 Views
Slider
This is a migrated thread and some comments may be shown as answers.
haleh
Top achievements
Rank 1
haleh asked on 04 Dec 2017, 08:32 AM

Hello,

I have a radgrid and in each row I have a radslider. I want to change the value of the radslider and save it into the database at the same time by clicking on the radslider. Below you can find the radslider in radgrid:

 

<telerik:GridTemplateColumn>
     <ItemTemplate>
                  <telerik:RadSlider RenderMode="Lightweight" ID="RS_Severity" runat="server" Orientation="Horizontal"  
                    LargeChange="1" TrackPosition="TopLeft" ShowIncreaseHandle="false"
                  AutoPostBack="true"  OnValueChanged="RS_Severity_ValueChanged" ShowDecreaseHandle="false" Width="170"
                  ItemType="item" Font-Size="Smaller" Height="35" Skin="Web20" CssClass="TicksSlider ml-1 mr-1">
                                                            
             <Items>
                    <telerik:RadSliderItem Text="Normal"  ToolTip="Normal" runat="server"></telerik:RadSliderItem>
                   <telerik:RadSliderItem Text="Average"  ToolTip="Average" runat="server"></telerik:RadSliderItem>
                    <telerik:RadSliderItem Text="Bad"  ToolTip="Bad" runat="server"></telerik:RadSliderItem>
                    <telerik:RadSliderItem Text="Very bad"  ToolTip="Very bad" runat="server"></telerik:RadSliderItem>
            </Items>
   </telerik:RadSlider>
       </ItemTemplate>
 </telerik:GridTemplateColumn>

 

In code behind I have a function for OnValueChanged event. 
the event will fire correctly by clicking on the slider. the problem is that I cannot get the id of the row on which i am clicking.

I have tried CommandName property for radslider but it did not work.

 

I appreciate any suggestion and help.

 

4 Answers, 1 is accepted

Sort by
0
haleh
Top achievements
Rank 1
answered on 04 Dec 2017, 08:51 AM
In case if you find to see how the interface is.
0
Eyup
Telerik team
answered on 07 Dec 2017, 08:34 AM
Hi Amin,

You can use the (sender as RadSlider).NamingContainer as GridDataItem to access the row. Once you have the item instance, you can use the GetDataKeyValue method to extract the corresponding ID:
http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/rows/accessing-cells-and-rows#accessing-raw-field-data-and-key-values

I hope this will prove helpful.

Regards,
Eyup
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
haleh
Top achievements
Rank 1
answered on 07 Dec 2017, 10:03 AM

Dear Eyup,

Thank you for the reply.

I have tried CommandName for radslider, in this scenario the OnItemCommand event  for radgrid does not fire. 

The second scenario was using OnValueChanged event in radslider. In this case I do not have access to selected item in radgrid.

Your solution is not good enough for me, because the CommandName is not recognized OnItemCommand event. Since when the user click the radslider, the radgrid row select is not fired.

 

Kind regards,

Amin

0
Eyup
Telerik team
answered on 12 Dec 2017, 09:47 AM
Hello Amin,

In this case you can remove or disable the AutoPostBack property of the RadSlider and use its client-side value changed event handler to fire a custom grid command using the following method:
http://www.telerik.com/help/aspnet-ajax/grid-gridtableview-firecommand.html

That should do the trick.

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