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

Checkbox issue with browser back button

1 Answer 549 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Brennan
Top achievements
Rank 1
Brennan asked on 17 Oct 2010, 03:08 AM
I have a RadGrid setup with a GridClientSelectColumn and AllowMultiRowSelection = false. When the page is posted back and I hit the browser back button, the previously selected checkbox is still checked. When I check another row, the first one stays checked causing two checkboxes to be checked. On top of that, it's a real pain to uncheck the first checkbox for an end-user.

Telerik has confirmed that this is not a bug with RadGrid but a browser issue, and it will be difficult to deal with since the page is not reloaded when using the browser back button.

Can anyone think of a way to clear the RadGrid checkboxes after hitting the back button?

Example:
- Go to: http://demos.telerik.com/aspnet-ajax/grid/examples/client/selecting/defaultcs.aspx
- Uncheck: (you may have to do a post back to persist this setting)
- Check a row in the 2nd grid (Grid with ClientSideSelectColumn)
- Click the PostBack button
- Hit your browser's back button
- Check another row
- You will see that the previous row stays checked along with the new one
- Now, try to get the original row unchecked

1 Answer, 1 is accepted

Sort by
0
Vasil
Telerik team
answered on 21 Oct 2010, 01:28 PM
Hello David,

You can use this javascript:

<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
    <script type="text/javascript">
 
        function GridCreated(sender, eventArgs) {
 
            var items = document.getElementsByTagName("INPUT")
            var i = items.length;
            var item;
            do {
                item = items[i-1];
                if (item.type == "checkbox") {
                    item.checked = false;
                }
            }
            while (--i);
        }           
    </script>
</telerik:RadCodeBlock>

And do not forget to register this function on grid's client-side event OnGridCreated.
<telerik:RadGrid ID="RadGrid1" runat="server" .... >
       <ClientSettings EnableRowHoverStyle="true">
           <Selecting AllowRowSelect="True" />
           <ClientEvents OnGridCreated="GridCreated" />
       </ClientSettings>

Regards,
Vasil
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Brennan
Top achievements
Rank 1
Answers by
Vasil
Telerik team
Share this question
or