This question is locked. New answers and comments are not allowed.
I have a GridView bound to a a DomainDataService using a VirtualQuaryableCollectionView. I have added some default ColumnFilterDescriptors that are always applied for the first load. The intention of the default filter descriptors is to restrict the viewed result to the most common items.
This works perfectly as long as there is at least one (1) row returned with the default filter set. The grid is displayed with the resulting row(s) and the filter icons are displayed in the column headers. The user can alter (or remove) the default filters and get a more complete result set if required.
But if the initial load (based on the default filters) does not return any rows at all, an empty GridView is displayed an no filter icons are present in the column headers. Hence the user cannot alter the filters to get a more complete result (since the filter icons simply aren't present).
How can I configure the GridView to always display the filter icons in the column headers, even if the GridView is empty?
(using Q1 2011)
This works perfectly as long as there is at least one (1) row returned with the default filter set. The grid is displayed with the resulting row(s) and the filter icons are displayed in the column headers. The user can alter (or remove) the default filters and get a more complete result set if required.
But if the initial load (based on the default filters) does not return any rows at all, an empty GridView is displayed an no filter icons are present in the column headers. Hence the user cannot alter the filters to get a more complete result (since the filter icons simply aren't present).
How can I configure the GridView to always display the filter icons in the column headers, even if the GridView is empty?
(using Q1 2011)
11 Answers, 1 is accepted
0
Hello Gunnar,
You need to set the DataType property on your Columns.
RadGridView depends on the DataType of each Column to generate a filtering interface. If no DataType is specified, RadGridView reflects it from the first item in contains. If it contains no items and no DataType is specified for a Column, RadGridView cannot generate the filtering UI for that Column.
Kind regards,
Yavor Georgiev
the Telerik team
You need to set the DataType property on your Columns.
RadGridView depends on the DataType of each Column to generate a filtering interface. If no DataType is specified, RadGridView reflects it from the first item in contains. If it contains no items and no DataType is specified for a Column, RadGridView cannot generate the filtering UI for that Column.
Kind regards,
Yavor Georgiev
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
Gunnar
Top achievements
Rank 1
answered on 19 Apr 2011, 06:15 PM
Can I do this in XAML? What is the syntax? I have tried...
DataType = "string"
DataType = "String"
DataType = "System.String"
DataType = "typeof(string)"
All fail...
DataType = "string"
DataType = "String"
DataType = "System.String"
DataType = "typeof(string)"
All fail...
0
Hello Gunnar,
Unfortunately, you cannot specify types in XAML under Silverlight.
All the best,
Yavor Georgiev
the Telerik team
Unfortunately, you cannot specify types in XAML under Silverlight.
All the best,
Yavor Georgiev
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
Gunnar
Top achievements
Rank 1
answered on 19 Apr 2011, 08:39 PM
OK, where can I attach the code that set the DataType on the GridView columns?
I have tried most of the events available for the GridView, but the columns are always null (not yet created). Do I have to create the columns in code as well, or is there some event I can attach to when the columns have been created?
I have tried most of the events available for the GridView, but the columns are always null (not yet created). Do I have to create the columns in code as well, or is there some event I can attach to when the columns have been created?
0
Hello Gunnar,
I would need to know a bit more about your scenario before I can say. Could you please post the XAML of your page there the GridView and the domain data controls are?
Best wishes,
Yavor Georgiev
the Telerik team
I would need to know a bit more about your scenario before I can say. Could you please post the XAML of your page there the GridView and the domain data controls are?
Best wishes,
Yavor Georgiev
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
Gunnar
Top achievements
Rank 1
answered on 19 Apr 2011, 09:52 PM
The XAML for the GridView:
The code using VirtualQueryableCollectionView() according to your recommendations:
<telerik:RadGridView Name="radGridView1" AutoGenerateColumns="False" ScrollViewer.VerticalScrollBarVisibility="Auto" DataLoaded="radGridView1_DataLoaded" LayoutUpdated="radGridView1_DataLoaded" Loaded="radGridView1_Loaded" CanUserDeleteRows="False" CanUserInsertRows="False" IsFilteringAllowed="True" RowIndicatorVisibility="Collapsed" ShowGroupPanel="False" ItemsSource="{Binding}" MinHeight="400" DistinctValuesLoading="RadGridView1_DistinctValuesLoading" IsReadOnly="True" Grid.Row="0"> <telerik:RadContextMenu.ContextMenu> <telerik:RadContextMenu x:Name="GridContextMenu" Opened="GridContextMenu_Opened" ItemClick="GridContextMenu_ItemClick" /> </telerik:RadContextMenu.ContextMenu> <telerik:RadGridView.Columns> <telerik:GridViewDataColumn x:Name="SubjectColumn" Header="Subject" DataMemberBinding="{Binding SubjectName}" ShowDistinctFilters="False" ShowFieldFilters="True" IsSortable="True" Width="Auto" /> <telerik:GridViewDataColumn x:Name="EmailColumn" Header="Email" DataMemberBinding="{Binding Email}" ShowDistinctFilters="False" ShowFieldFilters="True" IsSortable="True" Width="Auto"/> <telerik:GridViewDataColumn x:Name="StatusColumn" Header="Status" DataMemberBinding="{Binding Path=CombinedCertState, Converter={StaticResource CertificateStateConverter1}}" ShowDistinctFilters="True" ShowFieldFilters="False" IsSortable="True" Width="Auto"/> <telerik:GridViewDataColumn x:Name="TemplateColumn" Header="Template" DataMemberBinding="{Binding TemplateName}" ShowDistinctFilters="True" ShowFieldFilters="False" IsSortable="True" Width="Auto"/> <telerik:GridViewDataColumn x:Name="ValidFromColumn" Header="Valid from" DataMemberBinding="{Binding NotBefore}" ShowDistinctFilters="False" ShowFieldFilters="True" IsSortable="True" Width="Auto"/> <telerik:GridViewDataColumn x:Name="ValidToColumn" Header="Valid to" DataMemberBinding="{Binding NotAfter}" ShowDistinctFilters="False" ShowFieldFilters="True" IsSortable="True" Width="Auto"/> <telerik:GridViewDataColumn x:Name="HashColumn" Header="Certificate Hash" DataMemberBinding="{Binding CertificateHash}" ShowDistinctFilters="False" ShowFieldFilters="True" IsSortable="True"/> <telerik:GridViewDataColumn x:Name="ServerColumn" Header="CA Server" DataMemberBinding="{Binding CAServer}" ShowDistinctFilters="False" ShowFieldFilters="True" IsSortable="True"/> <telerik:GridViewDataColumn x:Name="MessageColumn" Header="Message" DataMemberBinding="{Binding DispositionMessage}" ShowDistinctFilters="False" ShowFieldFilters="True" IsSortable="True"/> <telerik:GridViewDataColumn x:Name="RevokedReasonColumn" Header="Revoked Reason" DataMemberBinding="{Binding Path=RevokedReason, Converter={StaticResource RevokedReasonToTextConverter1}}" ShowDistinctFilters="True" ShowFieldFilters="False" IsSortable="True"/> <telerik:GridViewDataColumn x:Name="RevokedWhenColumn" Header="Revoked When" DataMemberBinding="{Binding RevokedWhen}" ShowDistinctFilters="False" ShowFieldFilters="True" IsSortable="True"/> </telerik:RadGridView.Columns></telerik:RadGridView>The code using VirtualQueryableCollectionView() according to your recommendations:
var view = new VirtualQueryableCollectionView() { LoadSize = 50, VirtualItemCount = 200 }; view.FilterDescriptors.CollectionChanged += (s, e) =>{ if (view.FilterDescriptors.Count == 0) { view.VirtualItemCount = 200; }}; view.ItemsLoading += (s, e) =>{ if (!shouldLoad) { shouldLoad = true; return; } var queryToLoad = query.IncludeTotalCount(true). Sort(view.SortDescriptors). Where(view.FilterDescriptors). Skip(e.StartIndex). Take(e.ItemCount); context.Load<Data_CertificateInfo>(queryToLoad).Completed += (sender, args) => { var lo = (LoadOperation)sender; this.RowCount.Text = lo.TotalEntityCount.ToString(); if (lo.TotalEntityCount != -1 && lo.TotalEntityCount != view.VirtualItemCount) { shouldLoad = false; view.VirtualItemCount = lo.TotalEntityCount; } view.Load(e.StartIndex, lo.Entities); };};DataContext = view;0
Hello Gunnar,
Since you are defining your columns in XAML, they should be available immediately after the call to InitializeComponent() in your XAML page's code-behind.
Kind regards,
Yavor Georgiev
the Telerik team
Since you are defining your columns in XAML, they should be available immediately after the call to InitializeComponent() in your XAML page's code-behind.
Kind regards,
Yavor Georgiev
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
Gunnar
Top achievements
Rank 1
answered on 19 Apr 2011, 10:41 PM
Maybe I'm doing this the wrong way. If I look at the Columns collection in the GridView, the columns are there, but if I try to access the columns using the x:Name defined in the XAML, they're not.
I have it like this:
For what I can tell, "this.SubjectColumn" is always null, regardless of how many rows the GridView contain. Odd..
Do you have any recommended alternate way to locate the column and set the DataType?
I have it like this:
<telerik:GridViewDataColumn x:Name="SubjectColumn" Header="Subject" DataMemberBinding="{Binding SubjectName}" ShowDistinctFilters="False" ShowFieldFilters="True" IsSortable="True" Width="Auto" />this.SubjectColumn.DataType = typeof(string);For what I can tell, "this.SubjectColumn" is always null, regardless of how many rows the GridView contain. Odd..
Do you have any recommended alternate way to locate the column and set the DataType?
0
Accepted
Hi Gunnar,
Because a GridViewColumn is a logical object in a collection, not an element on the page, even if you use the x:Name attribute on it, the Silverlight runtime won't be able to assign it to the field of your page. You'll need to use the Columns collection of RadGridView instead.
You can access columns like you would items in a dictionary - the key is the value of the UniqueName property of the column, which by default is set to the path in the DataMemberBinding. So the UniqueName of your SubjectColumn is "SubjectName", because that is the path in the column's DataMemberBinding.
Regards,
Yavor Georgiev
the Telerik team
Because a GridViewColumn is a logical object in a collection, not an element on the page, even if you use the x:Name attribute on it, the Silverlight runtime won't be able to assign it to the field of your page. You'll need to use the Columns collection of RadGridView instead.
var column = this.radGridView1.Columns["SubjectName"] as GridViewBoundColumnBase;if (column != null){ column.DataType = typeof(string);}You can access columns like you would items in a dictionary - the key is the value of the UniqueName property of the column, which by default is set to the path in the DataMemberBinding. So the UniqueName of your SubjectColumn is "SubjectName", because that is the path in the column's DataMemberBinding.
Regards,
Yavor Georgiev
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
Gunnar
Top achievements
Rank 1
answered on 20 Apr 2011, 10:01 AM
Perfect, thanks. I realized that the type must correspond to the underlying data type, not the effect of any converter, but that's probably rather obvious when you think about it :-)
0
Allan Michaelsen
Top achievements
Rank 1
answered on 08 Aug 2011, 05:44 AM
Hi Telerik
I had the same problem as gunnar and this almost fixed it, but... When the filter icon is pressed there's no content in the dropdownbox and the filters are therefor unusable. Am i missing something for the content to register and the filter work or?
I'd love some advice to this...
Allan
I had the same problem as gunnar and this almost fixed it, but... When the filter icon is pressed there's no content in the dropdownbox and the filters are therefor unusable. Am i missing something for the content to register and the filter work or?
<telerik:RadDataPager Grid.Row="0" Source="{Binding DataView, ElementName=DomainDataSourceToDoItems}" DisplayMode="All" IsTotalItemCountFixed="True" /> <telerik:RadGridView x:Name="radGridView" Grid.Row="1" CanUserFreezeColumns="False" RowIndicatorVisibility="Collapsed" ItemsSource="{Binding DataView, ElementName=DomainDataSourceToDoItems}" IsBusy="{Binding IsBusy, ElementName=DomainDataSourceToDoItems}" ShowGroupPanel="False" AutoGenerateColumns="False" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto" telerik:Theming.Theme="Windows7"> <telerik:RadGridView.Columns> <telerik:GridViewDataColumn UniqueName="Project" IsReadOnly="True" Width="100" DataMemberBinding="{Binding ToDoList, Converter={StaticResource ProjectNameConverter}}"> <telerik:GridViewDataColumn.Header> <TextBlock Margin="2" Text="Projekt" Style="{x:Null}" /> </telerik:GridViewDataColumn.Header> <telerik:GridViewDataColumn.CellTemplate> <DataTemplate> <TextBlock Height="20" Margin="2" Text="{Binding ToDoList, Converter={StaticResource ProjectNameConverter}}" TextWrapping="NoWrap" Style="{x:Null}" /> </DataTemplate> </telerik:GridViewDataColumn.CellTemplate> </telerik:GridViewDataColumn>public Home() { InitializeComponent(); foreach (var column in radGridView.Columns) { if (column != null) { switch (column.UniqueName) { case "Project": ((GridViewBoundColumnBase)column).DataType = typeof(string); break; } } } }Allan