Cancel postback on clicking the row that is already selected

4 posts, 1 answers
  1. cookies please
    cookies please avatar
    6 posts
    Member since:
    Jun 2015

    Posted 27 Aug 2015 Link to this post

    Using version 2015.2.623.45, RadGrid posts back when selecting the same row...

    <ClientSettings AllowColumnsReorder="True" AllowDragToGroup="True" EnablePostBackOnRowClick="True">
         <Selecting AllowRowSelect="True" EnableDragToSelectRows="False" />
         <Scrolling AllowScroll="True" UseStaticHeaders="True" />
         <Resizing AllowColumnResize="True" AllowResizeToFit="True" EnableRealTimeResize="True" />
    </ClientSettings>

    Is there a ClientSettings-Selecting property that can be set or a javascript snippet to disallow postback when the selected row is selected again?

    We'd like to avoid using the ClientSelectColumn.

    Thanks!

  2. cookies please
    cookies please avatar
    6 posts
    Member since:
    Jun 2015

    Posted 31 Aug 2015 Link to this post

    Is this even possible?

     It seems the row is deselected before the new row gets selected so there isn't an easy way to tell if a new row is being selected.

  3. Answer
    Eyup
    Admin
    Eyup avatar
    3664 posts

    Posted 01 Sep 2015 Link to this post

    Hello,

    This behavior is not related to Selecting - it rather depends on the EnablePostBackOnRowClick property. It will cause a postback every time the user clicks on a grid row. In order to prevent that, you can use the following approach:
    <ClientSettings EnablePostBackOnRowClick="true">
        <Selecting AllowRowSelect="true" />
        <ClientEvents OnRowClick="rowClick" />
    </ClientSettings>
    JavaScript:
    function rowClick(sender, args) {
        sender.ClientSettings.EnablePostBackOnRowClick =
            !args.get_gridDataItem().get_selected();
    }

    Hope this helps. Please give it a try and let me know if it works for you.

    Regards,
    Eyup
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  4. cookies please
    cookies please avatar
    6 posts
    Member since:
    Jun 2015

    Posted 01 Sep 2015 in reply to Eyup Link to this post

    Thanks for the simple solution.  This works great!
Back to Top