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

[Solved] How to add distinct filters when using DDS

4 Answers 129 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Michael MSTG
Top achievements
Rank 1
Michael MSTG asked on 06 Oct 2010, 03:49 PM
I'm using the grid view loaded by a domain data source.  I have several columns bound to a boolean property but I'm templating out the column to display a friendly "yes/no" instead of a checkbox.  What I'm looking to see if it is possible is use the distinct filters to programmatically show "yes/no" and have them behave as a "true/false."  I would like to make it so the distinct filters do not pick up any of the loaded data either (since more often than not, it does not load all distinct values anyway). 

Column example:

<telerik:GridViewDataColumn ShowFieldFilters="False" DataMemberBinding="{Binding IsEnabled}">
<telerik:GridViewDataColumn.CellTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding IsEnabled, Converter={StaticResource BooleanToStringConverter}}" />
</StackPanel>
</DataTemplate>
</telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>

 

 


Is this possible to do?

4 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 06 Oct 2010, 04:00 PM
Hello Michael,

 You can apply the same converter for the column DataMemberBinding and the grid filter will use it. Here is an example:

<telerik:GridViewDataColumn ShowFieldFilters="False" DataMemberBinding="{Binding IsEnabled, Converter={StaticResource BooleanToStringConverter}}">
    <telerik:GridViewDataColumn.CellTemplate>
        <DataTemplate>
            <StackPanel>
                <TextBlock Text="{Binding IsEnabled, Converter={StaticResource BooleanToStringConverter}}" />
            </StackPanel>
        </DataTemplate>
    </telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>

All the best,
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
Michael MSTG
Top achievements
Rank 1
answered on 06 Oct 2010, 04:04 PM
the problem here is the DDS may not load all distinct values.  We actually have a situation where the first 50 records are all "true" on this column.  I'd rather manually attempt to add the "false" filter for the user to select than use another database call only to get the one filter.  Is it not possible to add the single filter for the user to select?
0
Vlad
Telerik team
answered on 06 Oct 2010, 04:05 PM
Hi Michael,

 If you want to download all distinct values you can use the approach I've used in this blog post. 

All the best,
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
Michael MSTG
Top achievements
Rank 1
answered on 03 Nov 2010, 04:56 PM
The route we ended up going was as follows:

Private Sub gridView_DistinctValuesLoading(ByVal sender As Object, ByVal e As Telerik.Windows.Controls.GridView.GridViewDistinctValuesLoadingEventArgs) Handles dgView.DistinctValuesLoading 

Dim distinctValues As New List(Of Boolean)()
distinctValues.Add(
True)
distinctValues.Add(
False)
e.ItemsSource = distinctValues
End Sub

This allowed us to control the distinct while not caring what the DDS loaded up (and not having to make a 2nd database call to get distinct values). 
Tags
GridView
Asked by
Michael MSTG
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Michael MSTG
Top achievements
Rank 1
Share this question
or