Enable disable radgrid from client side on a button click

4 posts, 0 answers
  1. Lokesh
    Lokesh avatar
    89 posts
    Member since:
    Jul 2012

    Posted 15 Jun 2013 Link to this post

    Hi Team, 
    I have a form with a radgrid and two buttons viz. Enable and Disable.
    When I click Disable, grid should get disabled with its paging, sorting, filtering and every property disabled.
    When I click Enable, grid should get enabled with all its properties enabled.

    I tried what has been said in this link.
    But this link shows a way only to disable the grid from client side script. For enabling the grid, I need to fire the AjaxRequest event which I don't want to.
    Also, the paging property does not get disabled.
    I can still change the page index or page size, which causes postback and enables the grid again.

    Could you please help me to enable and disable the grid from client side??
    Any help appreciated.

    Thanks,
    Lok..
  2. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 19 Jun 2013 Link to this post

    Hi,

    If I understand correctly you would like to have client-side disabling/enabling of the RadGrid and you would like the controls not to be Ajax-ified.

    You could achieve that with the approach you are referring to. However you would need to make minor modifications. The pager in the RadGrid has submit buttons and they should be added to the disabled input types in the DisableGrid() function.

    To enable the Grid you could take advantage of the fact that its settings are refreshed on postback. You could modify the enable button to be a submit button. Clicking the button would cause a postback, the RadGrid would be loaded again and will be enabled.

    You would find a sample project attached as illustration. I hope this would be helpful to you.

    Regards,
    Viktor Tachev
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mark
    Mark avatar
    1 posts
    Member since:
    Apr 2013

    Posted 16 Aug 2013 Link to this post

    Hi, I am using this sample and have noticed that it does not disable the change Page Size functionality when the pager style mode = NextPrevAndNumeric as below:

    <PagerStyle AlwaysVisible="true" Position="Bottom" PageSizeControlType="RadComboBox" Mode="NextPrevAndNumeric" />.

    Can you please advise me on how to disable this?

    Regards,
    Mark.
  5. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1793 posts

    Posted 21 Aug 2013 Link to this post

    Hello Mark,

    Thank you for getting back to us.

    The behavior you are observing is caused due to the fact that with those PagerStyle settings, DOM elements that are outside the RadGrid are used. One approach that could be used in your scenario is to hide the drop down when disabling the grid. Please add the following to the DisableGrid() function provided by Victor:
    var tables = gridCtrl.get_element().getElementsByTagName("table");
    var tbody = $(tables[tables.length - 1]).find("tbody").empty();

    Please try the above and see if it works for you.

     

    Best Regards,
    Konstantin Dikov
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Back to Top