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

Cancel postback on clicking the row that is already selected

3 Answers 50 Views
Grid
This is a migrated thread and some comments may be shown as answers.
cookies please
Top achievements
Rank 1
cookies please asked on 27 Aug 2015, 03:49 PM

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!

3 Answers, 1 is accepted

Sort by
0
cookies please
Top achievements
Rank 1
answered on 31 Aug 2015, 07:10 PM

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.

0
Accepted
Eyup
Telerik team
answered on 01 Sep 2015, 06:16 AM
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
0
cookies please
Top achievements
Rank 1
answered on 01 Sep 2015, 12:53 PM
Thanks for the simple solution.  This works great!
Tags
Grid
Asked by
cookies please
Top achievements
Rank 1
Answers by
cookies please
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or