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

Custom filter for custom GridViewColumn

2 Answers 65 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Boukerroui
Top achievements
Rank 1
Boukerroui asked on 14 Jan 2015, 04:46 PM
I have ceate a custom filter (inherit from IFilteringControl) with 2 chekbox (values : All and Present) and want to apply it for a custom GridViewColumn
<telerikGridView:GridViewColumn UniqueName="Commandes_MultiSources"
        HeaderCellStyle="{StaticResource HeaderCellSmallStyle}"
        IsVisible="False"
        IsSortable="False"
        IsReadOnly="True">
    <telerikGridView:GridViewColumn.CellTemplate>
        <DataTemplate>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Column="0" x:Name="Present"
                           TextDecorations="Underline"
                           Cursor="Hand" HorizontalAlignment="Center"
                           Text="{Binding MultiSourcesPresent}"
                           MouseLeftButtonUp="MultiSources_MouseLeftButtonUp"/>
                <TextBlock Grid.Column="1" x:Name="Tous"
                           TextDecorations="Underline"
                           Cursor="Hand" HorizontalAlignment="Center"
                           Text="{Binding MultiSourcesTous}"
                           MouseLeftButtonUp="MultiSources_MouseLeftButtonUp"/>
            </Grid>
        </DataTemplate>
    </telerikGridView:GridViewColumn.CellTemplate>
    <telerikGridView:GridViewColumn.Header>
        <Grid Width="Auto" HorizontalAlignment="Stretch">
            <Grid.RowDefinitions>
                <RowDefinition Height="50*"/>
                <RowDefinition Height="50*"/>
            </Grid.RowDefinitions>
            <TextBlock Grid.Row="0" Padding="0 0 0 2" TextAlignment="Center" Text="multi_source"/>
            <Grid Grid.Row="1">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="50*" />
                    <ColumnDefinition Width="50*"/>
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Column="0" Padding="0 2 20 0" TextAlignment="Center" Text="Present" />
                <TextBlock Grid.Column="1" Padding="5 2 0 0" TextAlignment="Center" Text="All" />
            </Grid>
        </Grid>
    </telerikGridView:GridViewColumn.Header>
    <telerikGridView:GridViewColumn.FilteringControl>
        <UCPlanipe:FilterControlMultiSource/>
    </telerikGridView:GridViewColumn.FilteringControl>
</telerikGridView:GridViewColumn>

in custom filter i cant not use GridViewBoundColumnBase  and i have error (NullReferenceException) in OnFilter method (line 8)
01.private void OnFilter(object sender, RoutedEventArgs e)
02.        {
03.            CreateFilters();
04.            try
05.            {
06.                if (!this.column.DataControl.FilterDescriptors.Contains(this.compositeFilter))
07.                {
08.                    this.column.DataControl.FilterDescriptors.Add(this.compositeFilter);
09.                }
10.                this.IsActive = true;
11.                OnFiltredComplet();
12.            }
13.            catch (Exception ex)
14.            {
15.                // error message is : Object reference not set to an instance of an object
16.            }
17.        }

2 Answers, 1 is accepted

Sort by
0
Accepted
Dimitrina
Telerik team
answered on 16 Jan 2015, 05:30 PM
Hi,

May I ask you to check why this exception is thrown, is this.column null? How do you initialize this.column? Why do you use GridViewColumn and not GridViewBoundColumnBase? How do you intend to perform the filtering in that case? Please note filtering is a data operation which means it is done by building and executing a LINQ query appending proper Where clause over the source collection. 

Generally, you can refer to our online documentation on how to create a custom filtering control. For more practical project on this you can also check our CustomFilterControls online demo and  the "Custom FilterControl" SDK example running the SDK Samples Browser

Regards,
Dimitrina
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Boukerroui
Top achievements
Rank 1
answered on 19 Jan 2015, 08:41 AM
Hi,
tank you for response. My Linq expression  is not find.
Tags
GridView
Asked by
Boukerroui
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Boukerroui
Top achievements
Rank 1
Share this question
or