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

Disable RadGrid after click on save button on radtoolbar

1 Answer 104 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sahar
Top achievements
Rank 1
Sahar asked on 11 Jan 2014, 03:08 AM
I try to disable radgrid after click on save button of radtoolbar as in this link
http://www.telerik.com/help/aspnet-ajax/grid-enabled-conventions.html
 but it is not working
any help .......... thanks !

1 Answer, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 13 Jan 2014, 08:50 AM
Hi Sahar,

Unfortunately I couldn't replicate the issue at my end. Please have a look into the sample code snippet which works fine at my end.

ASPX:
<telerik:RadToolBar ID="RadToolBar1" runat="server" OnClientButtonClicked="DisableGrid">
    <Items>
        <telerik:RadToolBarButton Text="Save" runat="server">
        </telerik:RadToolBarButton>
    </Items>
</telerik:RadToolBar>
<telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="SqlDataSource1" AutoGenerateColumns="true">
</telerik:RadGrid>

JavaScript:
<script type="text/javascript">
    function DisableGrid(sender, args) {
        var gridCtrl = $find("<%=RadGrid1.ClientID %>");
        gridCtrl.get_element().disabled = "disabled";
        gridCtrl.ClientSettings.Selecting.AllowRowSelect = false;
        gridCtrl.ClientSettings.Resizing.AllowColumnResize = false;
        gridCtrl.ClientSettings.Resizing.AllowRowResize = false;
        gridCtrl.ClientSettings.AllowColumnsReorder = false;
        gridCtrl.ClientSettings.AllowDragToGroup = false;
        gridCtrl.ClientSettings.EnablePostBackOnRowClick = false;
        var links = gridCtrl.get_element().getElementsByTagName("a");
        var images = gridCtrl.get_element().getElementsByTagName("img");
        var inputs = gridCtrl.get_element().getElementsByTagName("input");
        var sortButtons = gridCtrl.get_element().getElementsByTagName("span");
        for (var i = 0; i < links.length; i++) {
            links[i].href = "";
            links[i].onclick = function () {
                return false;
            }
        }
        for (var i = 0; i < images.length; i++) {
            images[i].onclick = function () {
                return false;
            }
        }
        for (var i = 0; i < sortButtons.length; i++) {
            sortButtons[i].onclick = function () {
                return false;
            }
        }
        for (var i = 0; i < inputs.length; i++) {
            switch (inputs[i].type) {
                case "button":
                    inputs[i].onclick = function () {
                        return false;
                    }
                    break;
                case "checkbox":
                    inputs[i].disabled = "disabled";
                    break;
                case "radio":
                    inputs[i].disabled = "disabled";
                    break;
                case "text":
                    inputs[i].disabled = "disabled";
                    break;
                case "password":
                    inputs[i].disabled = "disabled";
                    break;
                case "image":
                    inputs[i].onclick = function () {
                        return false;
                    }
                    break;
                case "file":
                    inputs[i].disabled = "disabled";
                    break;
                default:
                    break;
            }
        }
    }
</script>

Hope this will helps you.
Thanks,
Shinu.
Tags
Grid
Asked by
Sahar
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or