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

Enable disable radgrid from client side on a button click

3 Answers 324 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Lokesh
Top achievements
Rank 1
Lokesh asked on 15 Jun 2013, 09:11 AM
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..

3 Answers, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 19 Jun 2013, 01:09 PM
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.
0
Mark
Top achievements
Rank 1
answered on 16 Aug 2013, 06:52 AM
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.
0
Konstantin Dikov
Telerik team
answered on 21 Aug 2013, 08:27 AM
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.
Tags
Grid
Asked by
Lokesh
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Mark
Top achievements
Rank 1
Konstantin Dikov
Telerik team
Share this question
or