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

Grid filter – It doesn’t display all the values and shows duplicates

4 Answers 148 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Attila Pados
Top achievements
Rank 1
Attila Pados asked on 26 Sep 2012, 11:15 AM

A part of a table shows the following datas:

[picture1.png]

The quick filter (Funnel Icon) doesn’t show all the values from the selectable items.

[picture2.png]

 

It seems well in the list, that the numbers are in ascending order, but more than one value which is in the table is missing from it (eg. ’-0,49’ or ’6,00’in the upper picture), and more than one value is duplicated (eg. ’-8,51’).

Informations and source code:

<Style x:Key="RightAlignedGridColumnStyle" TargetType="{x:Type telerik:GridViewDataColumn}">

      <Setter Property="TextAlignment" Value="Right"/>

</Style>

<Style x:Key="PercentGridColumnStyle" TargetType="{x:Type telerik:GridViewDataColumn}"

         BasedOn="{StaticResource ResourceKey=RightAlignedGridColumnStyle}">

      <Setter Property="DataFormatString" Value="{}{0:N2}"/>

</Style>

 

<telerik:GridViewDataColumn Width="185" Header="Low pr % to Normal pr orig"

     DataMemberBinding="{Binding LowPriceToEDLPOriginal}"

     Style="{StaticResource ResourceKey=PercentGridColumnStyle}">

</telerik:GridViewDataColumn>

 

  • LowPriceToEDLPOriginal: Receive from database, with not only two, but three digits after the decimal. Presumably the duplications occur because of this, because there is a ‘-8,511’ and a ‘-8,512’ value in the database.

 

 

Is there any solution for our problem? Thank you for your answer!

 

4 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 26 Sep 2012, 11:51 AM
Hi,

Distinct values are extracted and ordered from the actual raw data values. String Formats and IValueConverters cannot be respected when this process happens. The string format and IValueConverter is only used for display purposes. They are not used for data manipulation purposes.

Thus, if you have the numbers 1.234 and 1.235 and you have applied a string format to show only the first two digits after the decimal point, in the distinct values list you will see:

1.23
1.23

These are two different numbers (1.234 and 1.235) but they look the same because there is a string format applied on them.

I hope this makes sense.

Your only workaround would be to make the list-box show the raw distinct values, instead of the formatted ones. To do that you should edit the ControlTemplate of the FilteringControl class and change the thing in yellow to read RawValue instead of ConvertedValue.
<ListBox.ItemTemplate>
    <DataTemplate>
        <CheckBox IsChecked="{Binding IsActive, Mode=TwoWay}"
              Content="{Binding ConvertedValue, Converter={StaticResource DistinctValueConverter}}"
              VerticalContentAlignment="Center"
              telerik:StyleManager.Theme="{StaticResource Theme}"/>
    </DataTemplate>
</ListBox.ItemTemplate>


Here you can learn more about distinct values.

Regards,
Ross
the Telerik team

Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

0
Attila Pados
Top achievements
Rank 1
answered on 01 Oct 2012, 11:57 AM
Hello,

thank you for your answer. Unfortunately i could not realise the solution.

The referred url is invalid. I can not open the example. Could you send me a short sample code?

Thanks in advance.

Best regards,
Attila
0
Dimitrina
Telerik team
answered on 01 Oct 2012, 12:18 PM
Hello,

You could find detailed information on how the filtering is actually performed in our online documentation. For a code example on how to predefine the template of the FilteringControl please check this help article.

Then change the CheckBox's Binding like so :
<ListBox.ItemTemplate>
    <DataTemplate>
        <CheckBox IsChecked="{Binding IsActive, Mode=TwoWay}"
                  Content="{Binding RawValue}"
                  VerticalContentAlignment="Center"
                  telerik:StyleManager.Theme="{StaticResource Theme}"/>
    </DataTemplate>
</ListBox.ItemTemplate>


Regards,
Didie
the Telerik team

Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

0
Attila Pados
Top achievements
Rank 1
answered on 26 Oct 2012, 08:03 AM

Hi!

Thanks for your answer.

Now your solution is working, the grid filter shows all of the values. But unfortunately it’s not perfect, because I have calculated fields in the grid. There are a lot of numbers which have six or seven digits after the decimal, but I don’t want to see all the digits, just two of them. The calculated fields calculated from other calculated fields, so it’s very important to always calculate with the long numbers.

Here is an example, it should work like this:

Number, what’s in the grid, use for calculate: 0.05111561

Number, what I should see in the grid: 0.05

In the quick filter I should also see 0.05. But if I have 0.0532511 besides to the previous number (0.05111561) in the grid, the quick filter should group these numbers under 0.05, so 0.05 should be shown only at once.

The ascending or descending ordering also works with the long numbers.

Is this practicable? If yes, could you send me a short example code?

Thanks in advance!

 

Tags
GridView
Asked by
Attila Pados
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Attila Pados
Top achievements
Rank 1
Dimitrina
Telerik team
Share this question
or