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

Show/Hide of RadGrid

1 Answer 136 Views
Grid
This is a migrated thread and some comments may be shown as answers.
chaitanya elluri
Top achievements
Rank 1
chaitanya elluri asked on 08 Jun 2010, 11:13 AM
Hi All,

I am displaying the entity data using a radgrid.
on the top of the grid i placed two imagse buttons
1. Show Fitler
2. Hide Filter

By default the filter of the Radgrid should be in hidden state and the hidebtn style property 'display' should be none.
when ever i click on the show filter button.... filter option of radgrid should be enabled and hide btn display property should be updated from 'none' to 'block' and show btn property should be update from 'block' to 'none'

Vice versa if we click on the hide button.
I tried doing this my implementing the below code...
------------------------------------javascript--------------------------------------

 

function ShowFilter() {

 

$find(

'<%=rgPluginsList.ClientID %>').get_masterTableView().showFilterItem();

 

document.getElementById(

'HideBtn').style.display = 'block';

 

document.getElementById(

'ShowBtn').style.display = 'none';

 

}

 

function HideFilter() {

 

document.getElementById(

'HideBtn').style.display = 'none';

 

document.getElementById(

'ShowBtn').style.display = 'block';

 

$find(

'<%=rgPluginsList.ClientID %>').get_masterTableView().hideFilterItem();

 

}

----------------------------------------------------------------------------------------------------

<

 

asp:ImageButton runat="server" OnClientClick="ShowFilter();" ImageUrl="../Images/ShowFilter.gif"

 

 

ID="ShowBtn" />

 

 

<asp:ImageButton runat="server" OnClientClick="HideFilter();" ImageUrl="../Images/HideFilter.gif"

 

 

ID="HideBtn" />

 

-----------------------------------------------------------------------------------------------------------
In the Page Load event :

if

 

(!IsPostBack)

 

{

HideBtn.Style.Add(

"display", "none");

 

ShowBtn.Style.Add(

"display", "block");

 

rgPluginsList.AllowFilteringByColumn = !rgPluginsList.AllowFilteringByColumn;

rgPluginsList.Rebind();

}

-------------------------------------------------------------------------------------------------------------


but after the second click of hide btn  i am getting the following exception
'

Server Error in '/RadarNetUI' Application.
--------------------------------------------------------------------------------

Multiple controls with the same ID 'FilterTextBox_#' were found. FindControl requires that controls have unique IDs.
Let me know wheter i missed some thing
Thanks in advance

Chaitanya.E
chaitanya.eluru@cosmonetsolutions.com


1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 08 Jun 2010, 01:32 PM
Hello Chaithanya,

I tried following approach and got it worked. Initially I set the imagebutton visibility from client side "pageLoad" function than from code behind.

Here is the code that I tried:
 
<script type="text/javascript">  
    function pageLoad() {  
        document.getElementById('HideBtn').style.display = 'block';  
        document.getElementById('ShowBtn').style.display = 'none';  
    }  
    function ShowFilter() {  
        $find('<%=RadGrid1.ClientID %>').get_masterTableView().showFilterItem();  
        document.getElementById('HideBtn').style.display = 'block';  
        document.getElementById('ShowBtn').style.display = 'none';  
    }  
    function HideFilter() {  
        document.getElementById('HideBtn').style.display = 'none';  
        document.getElementById('ShowBtn').style.display = 'block';  
        $find('<%=RadGrid1.ClientID %>').get_masterTableView().hideFilterItem();  
    }  
</script> 

Give a try with this and see whether it helps.

Regards,
Princy.
Tags
Grid
Asked by
chaitanya elluri
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or