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

Programmatic filtering problems

6 Answers 114 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jon
Top achievements
Rank 1
Jon asked on 11 Jun 2009, 11:10 AM
Hi,

I have an application in which I will need to scan a barcode and then the matching record is displayed in a gridview.  Then the next bacode will be scanned and added etc. 

To that end I have got the scanning bit working and as each new barcode is scanned it gets added to an array.  I need to be able to get those array entries setup as the filter of the gridview. 

I would like to do this by setting up an initial filter that will search for record -1 which doesn't exist and as such the grid will be empty.  Then I can add the items in one at a time.  It would be nice and easy if I could do some form of an COLUMNNAME IN (1,2,3) operation on the grid like in SQL.

I have the following code present to add the column IDs to the filter.  It doesn't work.  I've tried a gridview refresh afterwards and no luck. 

Dim filter As Telerik.WinControls.Data.FilterExpression = New Telerik.WinControls.Data.FilterExpression()  
For Each columnID As String In columnIDs  
filter.Predicates.Add(Telerik.WinControls.Data.FilterExpression.BinaryOperation.OR, Telerik.WinControls.UI.GridKnownFunction.EqualTo, columnID)  
Next 
uxRadGridView.Columns("ColumnID").Filter = filter 

Any ideas?

best Regards,

Jon

6 Answers, 1 is accepted

Sort by
0
Jon
Top achievements
Rank 1
answered on 11 Jun 2009, 04:07 PM
OK I was doing something wrong.  I'd missed the parameters expression and also hadn't allowed the filter row to be active (EnableFiltering).

Is there a way to have programmatic filters and hide the filter row so the user cannot use it? 

Regards,

Jon
0
Martin Vasilev
Telerik team
answered on 12 Jun 2009, 04:10 PM
Hello Jon,

Thank you for writing.

You can easily hide the filter row by using GridTemplate's ShowFilteringRow property:
Me.radGridView1.MasterGridViewTemplate.ShowFilteringRow = False  

Also you can find detailed information how to apply filters programmatically in our documentation.

Do not hesitate to contact me again if you have other questions.

Greetings,
Martin Vasilev
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
Jon
Top achievements
Rank 1
answered on 12 Jun 2009, 06:29 PM
Hi Martin,

Thanks for that - it works just fine now.  The odd thing was that when I was setting the filter to not be visible via the designer it then didn't work but there could have been some other issue there I suppose.

I am still getting one problem with my code that you may have an idea on.  A lot of the time when I rebuild the filter after having taken out a value from it the grid doesn't seem to refresh although a click on the grid seems to kick it in.  The odd thing is that if I step through the code it all works and always refreshes the grid properly, the problem ONLY appears when I let the code run straight through with no pauses.  Any thoughts?

Regards,

Jon
0
Martin Vasilev
Telerik team
answered on 18 Jun 2009, 05:51 AM
Hello Jon,

Thank you for getting back to me.  After changing filtering the RadGridView needs to refresh its view. You can try calling the Update method with FilteringChanged or Reset argument:
((GridTableElement)this.radGridView1.GridElement).Update(GridUINotifyAction.FilteringChanged); 

Write me back if you need additional assistance.

Greetings,
Martin Vasilev
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
Jon
Top achievements
Rank 1
answered on 18 Jun 2009, 08:01 AM
Hi Martin,

You're a star, thanks very much for that!

For anyone else doing this you may also need to make sure that the currently selected row also gets cleared first as it caused a problem on my setup.

uxRadGridView.CurrentRow =

Nothing

Cheers,

Jon

 

0
Martin Vasilev
Telerik team
answered on 23 Jun 2009, 02:19 PM
Hello Jon,

Thank you for sharing your experience with us. Do not hesitate to contact me again if you have other question.

Greetings,
Martin Vasilev
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
GridView
Asked by
Jon
Top achievements
Rank 1
Answers by
Jon
Top achievements
Rank 1
Martin Vasilev
Telerik team
Share this question
or