Unplanned
Last Updated: 07 Apr 2023 12:38 by ADMIN
SWAT
Created on: 03 Apr 2023 16:12
Category: UI for ASP.NET AJAX
Type: Feature Request
1
In RadGrid, Prevent postback on rowclick when the row is already selected

Currently, when the grid is set to:

<ClientSettings EnablePostBackOnRowClick="true">

The post back will be fired even if the clicked row is already selected, which sometimes is not good.

To solve this we need to write a javascript event on rowclick to cancel the event if the row is already selected, but it will be nice to have this as a built in setting like 

<ClientSettings EnablePostBackOnRowClick="true" PostBackOnRowClickOnSelectedRow="false">

Thanks,

ilan.

1 comment
ADMIN
Doncho
Posted on: 07 Apr 2023 12:38

Thank you for your request, Ilan!

Here is a workaround that can be used while such a feature is not present in the RadGrid:

Disable the EnablePostBackOnRowClick setting on the client temporarily when clicking on an already selected item and turn it back to enabled afterward:

<script>
    function rowClick(sender, args) {
        //if currently clicked item is already selected
        if (args.get_item().get_selected()) {
            //disable the auto postback feature
            sender.ClientSettings.EnablePostBackOnRowClick = false;
            setTimeout(function () {
                //bring back the feature on
                sender.ClientSettings.EnablePostBackOnRowClick = true;
            })
        }
    }
</script>

<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" Width="800px" OnNeedDataSource="RadGrid1_NeedDataSource">
    <ClientSettings EnablePostBackOnRowClick="true">
        <ClientEvents OnRowClick="rowClick"/>

I added your vote for the item so it is considered when the demand for this feature is being measured.

I am also rewarding you for submitting this feature request by adding some Telerik points to your account.

Kind regards,
Doncho
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.