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

Filtering on formatted numbers

7 Answers 90 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Esteban
Top achievements
Rank 1
Esteban asked on 01 Jun 2010, 09:33 PM

I have decimal (money and percentage) values in my grid, which original come in with 4 digits, but i'm displaying them with 2 by formatting them:

 

DataFormatString

 

 

="{}{0:N2}"

 

and

DataFormatString

 

 

="{}{0:P2}"

The values show up correctly in the filtering control, and i can filter by them, but when using the "Equals To", "Greater than or equals to", etc then i have to enter the value with 4 digits otherwise filtering doesn't seem to find the value.  Is there something that I can do so that the value is matched to the 2 digit represenation of the value?

 

7 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 02 Jun 2010, 07:11 AM
Hi Esteban,

When filtering is performed, the values are compared to the "raw" underlying data, i.e. the decimal value with four digits.

Let me try to explain why this is so. When you want to filter all values that are equal to let's say 12.34, this number is send through a LINQ query to the data source. If the number in the data source is let's say 12.3455 there is no way to reconstruct the last two digits (missing part) and send them to the LINQ query. There simply is not such information, because they might be 55, or 44, or anything else. No one know what they are. I hope this makes sense.

Therefore, your only option would be to add another public property (or DB field) to your business object that will return the rounded number and bind the column to this new property. You will not even need a DataFormatString if you do this. In this way the LINQ query can be sent with 12.34 as its value and it will match the record with raw value 12.3455 because it will compare the number against its "rounded" property which will be exactly 12.34. Thus filtering will be successful.

I hope this helps.

Regards,
Ross
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Zainab Vora
Top achievements
Rank 1
answered on 13 Oct 2010, 09:04 PM
I am facing a similar problem while filtering formatted numbers,

could creating a customized filter help?

I mean using a custom filter to intercept values going to LINQ query from the grid and then sending formatted value to it.

Is there any other way around for this?
0
Vlad
Telerik team
answered on 15 Oct 2010, 11:41 AM
Hello,

 You can create your own filtering control where you can embed your logic. Please check this demo for more info. 

Greetings,
Vlad
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Zainab Vora
Top achievements
Rank 1
answered on 15 Oct 2010, 02:14 PM
I am currently using Silverlight 3 (2010.2.714.1030). Is there a demo for Silverlight 3?
0
Vlad
Telerik team
answered on 15 Oct 2010, 02:20 PM
Hello,

 Here is the Silverlight 3 demo:
http://demos.telerik.com/silverlight/silverlight3/#GridView/CustomFilterControls

Greetings,
Vlad
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Zainab Vora
Top achievements
Rank 1
answered on 08 Nov 2010, 11:33 PM
Hi,

I would like my customized filter to have check-box for each distinct value. (For example the upper part of filter window with check-boxes  and leave out the lower bottom part of the filter where values can be entered using different filtering options)

Is there any demo to support that?

Or any tips to create filters to support distinct values filtering?

Thank you

0
Vlad
Telerik team
answered on 09 Nov 2010, 08:28 AM
Hi,

With custom filtering controls you can design the dialog in any way you want and put your own logic instead the default one. 

Best wishes,
Vlad
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Esteban
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Zainab Vora
Top achievements
Rank 1
Vlad
Telerik team
Share this question
or