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

Filter NumericType="Percentage"

3 Answers 236 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Curt
Top achievements
Rank 1
Curt asked on 20 May 2009, 05:55 PM
I can't get my GridNumericColumn to filter when the data is a percentage.  I can get the data formatted so that it shows as a percentage but the filtering doesn't work.  When I filter the results are always GreaterThan the value I am trying to filter on.

<telerik:GridNumericColumn DataField="Completionhours" NumericType="Percent" DataType="System.Double" CurrentFilterFunction="GreaterThan"   UniqueName="Completionhours" HeaderText="Completion Rate" />
                               

3 Answers, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 25 May 2009, 11:38 AM
Hello Brent,

I tried to reproduce the problem but to no success as evidenced by the attached sample.

Please, take a look at it and let us know of the result.

Thank you.

Best regards,
Tsvetoslav
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
Curt
Top achievements
Rank 1
answered on 28 May 2009, 05:58 PM
The sample you sent me does not contain anything with percentages.  I am beginning to wonder if Telerik even reads the posts before posting a "solution".  The last several posts I have had responses to take 4-5 iterations before the actual problem is even addressed.

Please re-read my post below.  I can't get the filtering working when using percentages and can't find any samples of how it should be done.

-Brent
0
Tsvetoslav
Telerik team
answered on 29 May 2009, 09:17 AM
Hi Brent,

I am not sure what exactly your scenario is - what data is coming from the database and how you want to display it. On these two conditions depends the way in which you have to implement the filtering for the numeric column. For example, if you have a value of 0.3 in a database record, depending on the scenario, it can be treated as 30% or as 0.3%.

I assumed that your case is the latter since I noticed that you are not using any formatting for the data in display mode (based on the mark-up pasted). At the same time you pointed out that you manage to get the data displayed as percent values. Based on these two details - I thought that by displaying data as percentage values you had in mind the data entered in the filter box - which indeed displays as a percent. Therefore, I made the above assumption and implemented the UnitPrice column in my sample in the same way - and you should have noticed that the filtering works correctly for it.

Please, take into consideration the following details about the numeric column - I hope this information will help out to clear the misunderstanding:

1. If the data coming from the database is between 0 and 1, and you want to display it as percent values - then you need to specify a DataFormatString pattern: {0:#%}. However, upon filtering, the underlying values will be taken into account - i.e. if you have 30% displayed, 0.3 will be the value the filtering command will operate upon.

2. On the other hand, when you enter 30% in the filter box - the underlying value that the grid's filter command will work upon is 30, not 0.3. Therefore, if you apply a filter of GREATER THAN 29%, then the records having 30% displayed (and an actual value of 0.3) won't pass the filter condition - and you get incorrect filtering results.

For your convenience, I am sending you the sample reworked to the following scenario, which I hope is the one you are implementing:
    - the values in the database for the percent column should be multiplied by 100 to get their percent
      counterpart.
    - in display mode they need to be shown with a percent sign.
    - when a certain value is entered in the filter box, it will be devided by 100 and then the filter command
   applied.

I hope this information helps.

Best Regards,
Tsvetoslav
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
Curt
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Curt
Top achievements
Rank 1
Share this question
or