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

Is there any way to programatically clear all filter values on a rad grid using vb.net?

7 Answers 663 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Acadia
Top achievements
Rank 1
Iron
Acadia asked on 12 Mar 2009, 03:12 PM
I want to clear all filter item values programatically when I click on certain buttons.  How can I achieve this?

Thanks!

7 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 13 Mar 2009, 04:30 AM
Hi Acadia,

Try the following code snippets for clearing the filtering.

VB:
Protected  Sub Button2_Click(ByVal sender As ObjectByVal e As EventArgs) 
    RadGrid1.MasterTableView.FilterExpression = Nothing 
    RadGrid1.MasterTableView.Rebind() 
End Sub 

Thanks,
Shinu.


0
Acadia
Top achievements
Rank 1
Iron
answered on 18 Mar 2009, 05:00 PM
This seems to prevent the value from being used as a filter, which is good, but more specifically I'm looking to clear the actual filter text box for all filters and this code doesn't do that.  I tried the below code but it doesn't clear the grid's filter textboxes either.  Any suggestions?

Private

Sub clearRgHFilters()

 

 

 

For Each item As GridItem In rgH.Items

 

 

If TypeOf item Is GridFilteringItem Then

 

 

Dim filteringItem As GridFilteringItem = CType(item, GridFilteringItem)

 

 

Dim merchbox As TextBox = CType(filteringItem("MERCHANT_NAME").Controls(0), TextBox)

 

merchbox.Text =

""

 

 

Dim transcomp As TextBox = CType(filteringItem("TRANS_COMP").Controls(0), TextBox)

 

transcomp.Text =

""

 

 

Dim cardholder As TextBox = CType(filteringItem("SORTNAME").Controls(0), TextBox)

 

cardholder.Text =

""

 

 

Dim job As TextBox = CType(filteringItem("JOBNUM").Controls(0), TextBox)

 

job.Text =

""

 

 

Dim phase As TextBox = CType(filteringItem("PHASE").Controls(0), TextBox)

 

phase.Text =

""

 

 

Dim cat As TextBox = CType(filteringItem("CATEGORY").Controls(0), TextBox)

 

cat.Text =

""

 

 

Dim postdate As TextBox = CType(filteringItem("CMIC_POST_DATE").Controls(0), TextBox)

 

postdate.Text =

""

 

 

Dim transnum As TextBox = CType(filteringItem("SOURCE_TXN_NUMBER").Controls(0), TextBox)

 

transnum.Text =

""

 

 

Exit For

 

 

End If

 

 

Next

 

0
Accepted
Sebastian
Telerik team
answered on 18 Mar 2009, 05:03 PM
Hi Acadia,

See the code executed from the OnClick handler of the Clear Filters button on this online demo:

http://demos.telerik.com/aspnet-ajax/controls/examples/integration/gridandcombo/defaultcs.aspx?product=grid

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
Acadia
Top achievements
Rank 1
Iron
answered on 18 Mar 2009, 05:14 PM
Works perfectly thank you!
0
Richard Boarman
Top achievements
Rank 1
answered on 30 Jul 2009, 07:06 PM
I am using that exact code:

Protected

 

Sub clrFilters_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

 

 

For Each column As GridColumn In radGrid1.MasterTableView.Columns

 

column.CurrentFilterFunction = GridKnownFunction.NoFilter

column.CurrentFilterValue =

String.Empty

 

 

Next

 

radGrid1.MasterTableView.FilterExpression =

String.Empty

 

radGrid1.MasterTableView.FilterExpression =

Nothing

 

radGrid1.MasterTableView.Rebind()

 

End Sub

and when the grid rebinds, i get an empty first row
The size of the dataset did not change, but the grid is adding a blank row at the top. If I filter again, it is gone.
If I clear the filters by clearing the filter text in each column, I do not get the blank row, it only happens when clicking the "Clear Filters" button.

Any ideas?

 

0
Sebastian
Telerik team
answered on 31 Jul 2009, 11:31 AM

Hello Richard,

This is indeed an odd issue and unfortunately from the provided information I am not able to determine the exact cause of it. Can you provide a live url or a sample project (attached to a regular support ticket) which exhibits the abnormality? Thus I will do my best to advice you further.

Also verify that you are using the latest release 2009.2.701 of RadControls for ASP.NET AJAX in your project.

Kind 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
Hari
Top achievements
Rank 1
answered on 22 May 2012, 06:23 AM
Thanks Sebastian
Tags
Grid
Asked by
Acadia
Top achievements
Rank 1
Iron
Answers by
Shinu
Top achievements
Rank 2
Acadia
Top achievements
Rank 1
Iron
Sebastian
Telerik team
Richard Boarman
Top achievements
Rank 1
Hari
Top achievements
Rank 1
Share this question
or