Radslider in radgrid

5 posts, 0 answers
  1. Amin
    Amin avatar
    9 posts
    Member since:
    Feb 2012

    Posted 04 Dec 2017 Link to this post

    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.

     

  2. Amin
    Amin avatar
    9 posts
    Member since:
    Feb 2012

    Posted 04 Dec 2017 in reply to Amin Link to this post

    In case if you find to see how the interface is.
  3. Eyup
    Admin
    Eyup avatar
    3535 posts

    Posted 07 Dec 2017 Link to this post

    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.
  4. Amin
    Amin avatar
    9 posts
    Member since:
    Feb 2012

    Posted 07 Dec 2017 Link to this post

    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

  5. Eyup
    Admin
    Eyup avatar
    3535 posts

    Posted 12 Dec 2017 Link to this post

    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.
Back to Top