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

[Solved] filtering on off javascript

1 Answer 102 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Lee Malo
Top achievements
Rank 1
Lee Malo asked on 01 Feb 2010, 01:54 AM
I have used the example for turning filtering on and off with javascript and it works great. I moved the radio buttons into the command template of the radgrid and im not sure how to reference them. I used to check the state of the buttons on page load and hide it if the radio button for hide was selected. This allowed me to hide the filtering on start up. What syntax would I use to reference a radio button in the command template of a radgrid in javascript?

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 01 Feb 2010, 07:11 AM
Hi,

You can use a global registry (an array really) to store the  control ID's and emit script for every server control that will add an item to the global registry. Then just loop over all the  registered elements and get the one that contains the required server ID:

<CommandItemTemplate> 
                <asp:RadioButton ID="rdbtnHide" Text="Hide" GroupName="GroupA"  Checked="true" runat="server" /> 
                <asp:RadioButton ID="rdbtnShow" Text="Show" GroupName="GroupA" runat="server" /> 
           
                <script type="text/javascript"
                    registeredElements.push('<%# Container.FindControl("rdbtnHide").ClientID %>'); 
                    registeredElements.push('<%# Container.FindControl("rdbtnShow").ClientID %>'); 
               
                </script> 
 
</CommandItemTemplate>  
 
 
 
 

You can call the  GetRegisteredServerElement on a button click.

JS:
var registeredElements = []; 
function GetRegisteredServerElement() { 
     var clientID = ""
     for (var i = 0; i < registeredElements.length; i++) { 
     clientID = registeredElements[i]; 
     var object = document.getElementById(clientID); 
     if (object.value == 'rdbtnHide' && object.checked) { 
             $find("<%=RadGrid1.ClientID %>").get_masterTableView().hideFilterItem();  
      } 
     else if (object.value == 'rdbtnShow' && object.checked) { 
            $find("<%=RadGrid1.ClientID %>").get_masterTableView().showFilterItem();  
                } 
            } 
           
        }  

Thanks,
Princy
Tags
Grid
Asked by
Lee Malo
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or