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

[Solved] RadGrid Hide / Show Filter

12 Answers 1072 Views
Grid
This is a migrated thread and some comments may be shown as answers.
mauro.cecili
Top achievements
Rank 1
mauro.cecili asked on 26 May 2008, 08:55 AM
I sawed your example
http://www.telerik.com/demos/aspnet/prometheus/Grid/Examples/GeneralFeatures/Filtering/DefaultCS.aspx
I've tried to change this example
because i want that at page load filter is not visible.
If user need filter then click on the radio group.

How it's possibile to do this?
Thanks for your hel

12 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 26 May 2008, 09:01 AM
Hello mauro.cecili,

Here is an example:

            <script type="text/javascript">
                function pageLoad(sender, args)
                {
                    $find('<%=RadGrid1.ClientID %>').get_masterTableView().hideFilterItem();
                }
            </script>
 
Regards,
Vlad
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
mauro.cecili
Top achievements
Rank 1
answered on 26 May 2008, 09:20 AM
thank for yor help.
This is my scenario:
I have a RadMultiPage with two RadPageView
Every RadPageView contain an user control.
The user control contain a RadGrid with my personal code.
I have used your example im my user control.
Now i have this problem:
Your code is ok but only for the user control conatined in the first visible page of my RadMultiPage
How can i resolve it ?

I suppose that pageLoad event occur only for the visible page...
0
Iana Tsolova
Telerik team
answered on 26 May 2008, 12:45 PM
Hi mauro.cecili,

Please find attached a sample project where the filter items of the grids are hidden as expected. Try it on your end and let me know if I missed something from your logic.
  
Best wishes,
Iana
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
mauro.cecili
Top achievements
Rank 1
answered on 26 May 2008, 01:00 PM
I resolved my problem in his way.
Instead use function pageLoad as your sample,
i used GridCreated Client site event of radgird to execute code that hide filter items
            <script type="text/javascript">
                function GridCreated()
                {
                    $find('<%=RadGrid1.ClientID %>').get_masterTableView().hideFilterItem();
                }
            </script>
In page load event, on my user control, i assigned this event at every grid.
So every thing work fine.
using pageLoad only the last grid worked fine.
Thank for your help, now i'll take a look to your sample
I have a problem with Ajax enabled but i think it's only because i dont'use RegisterScriptClient

 
0
Ryan
Top achievements
Rank 1
answered on 30 Oct 2008, 09:49 PM
This example does not perform correctly because after a search the radio button for Yes remains selected however the filter textboxes are not there.  I'm looking to have the radio button for No checked when it loads.  If possible I would rather this be done with a checkbox than a radio button.

Thanks!
0
Iana Tsolova
Telerik team
answered on 03 Nov 2008, 08:49 AM
Hi Ryan,

You can find attached the sample modified so it uses checkbox to toggle the grid filter item visibility instead of radio button.

Let me know if any issues arise.

Sincerely yours,
Iana
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Bryan Smouse
Top achievements
Rank 1
answered on 02 Feb 2009, 05:31 PM
I implemented your example, but when the page loads, the filter items are visible initially for around a second then they disappear when the page load script runs. Is there any way to hide the filter items by default?  Thanks!
0
Iana Tsolova
Telerik team
answered on 03 Feb 2009, 11:59 AM
Hi Bryan,

Yes, you can hide the grid filter item initially. Try handling the ItemCreated event of RadGrid and hide the item as below:

protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)  
    {  
        if (!IsPostBack && e.Item is GridFilteringItem)  
        {  
            e.Item.Style["display"] = "none";  
        }  
    } 

I hope this helps.

Kind regards,
Iana
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
David
Top achievements
Rank 1
answered on 30 Apr 2009, 10:02 PM
I've got this working  by this method but i don't like the fact that the filter flashes on screen then hides.

I used to have this working with a checkbox  server side where I would set the Allowfilteringbycolumn = true when the check box changed.

Upgrading to the new version broke this.  I have a new custom drop down list for filtering.
If i do not turn on filetreing by default I get a null reference error on the filtering column javascript.

 

<telerik:GridBoundColumn UniqueName="Status" DataField="Status" HeaderText="Status" >

 

 

<FilterTemplate>

 

 

<telerik:RadComboBox ID="RadComboBoxStatus" DataSourceID="SqlDataSource2" DataTextField="Status"

 

 

DataValueField="Status" AppendDataBoundItems="true" SelectedValue='<%# TryCast(Container,GridItem).OwnerTableView.GetColumn("Status").CurrentFilterValue %>'

 

 

runat="server" OnClientSelectedIndexChanged="StatusIndexChanged">

 

 

<Items>

 

 

<telerik:RadComboBoxItem Text="All" />

 

 

</Items>

 

 

</telerik:RadComboBox>

 

 

 

<script type="text/javascript">

 

 

function StatusIndexChanged(sender, args) {

 

 

var tableView = $find("<%# TryCast(Container,GridItem).OwnerTableView.ClientID %>");

 

tableView.filter(

"Status", args.get_item().get_value(), "EqualTo");

 

}

 

</script> </FilterTemplate>

 

 

</telerik:GridBoundColumn>

 




I would sure love to see a server side solution for a grid with a custom drop down list to hide and show filters server side .


Anywhere to point me ?

0
Sebastian
Telerik team
answered on 04 May 2009, 10:38 AM
Hello David,

You can ajaxify the grid using RadAjaxManager or RadAjaxPanel to avoid the plain postback when the filtering item has to be shown/hidden. Another option would be to use client-side approach as demonstrated on this online demo:

http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/filtering/defaultcs.aspx (taking advantage of the showFilterItem()/hideFilterItem methods from the client-side API of the control)

Best regards,
Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
David
Top achievements
Rank 1
answered on 05 May 2009, 01:48 PM
I do have that example implemented and it works , as I stated.
I do have the grid in an Ajax panel with a script manager.... not the Rad ones, but it's there.

Here is the problem.  Take that example and turn OFF filtering by default then run it and you get javascript errors because the items are not created yet.

In mine the ajax update panel never gets hit since this is all happening client side and there is nothing really AJAX about it.  The screen display is changing.  

I'd still like to see the  example modified  to not use client side javascript code.
I've been trying ... believe me

I need:
1.  A grid with a drop down list filter using a datasource per current examples
2.  yes / no radio buttons for filters on / off  - Off is checked by default.
3. Grid set to allow filtering = false  as default
5. click On - ajax update panel fires and shows the filters
5. click off - ajax update panel fires and hidesthe filters

I had this scenario working with a checkbox, and a custom filtering class for a drop down list I found on your forum.
Since I upgraded, to 2009 that custom class no longer filtered the grid.  I think it had to do with fixing your double postback issue.

 
0
Iana Tsolova
Telerik team
answered on 08 May 2009, 07:55 AM
Hello David,

Could you please provide more information on the errors you received?
You could also try sending a runnable sample replicating them so we could debug it locally in order to find a resolution.

Greetings,
Iana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
mauro.cecili
Top achievements
Rank 1
Answers by
Vlad
Telerik team
mauro.cecili
Top achievements
Rank 1
Iana Tsolova
Telerik team
Ryan
Top achievements
Rank 1
Bryan Smouse
Top achievements
Rank 1
David
Top achievements
Rank 1
Sebastian
Telerik team
Share this question
or