While filtering is a very useful feature, it tends to confuse my test users in some cases, mostly in combination with other powerful features of the grid:
- If a filter is set and the column then hidden by the user, there is no visual indication of an active filter. This can be especially confusing in combination with the SaveLayout()/ LoadLayout() feature.
- On boolean columns there is no easy way to distinguish between a clear filter and an unchecked checkbox.
On my prototype application I have therefore implemented a 'Clear all Filters' Button, that is only enabled if any filters are set. In addition to indicate the filtering, clear all filters might be a useful standard function (for example in the context menu) of the grid.
Regards
Erwin
21 Answers, 1 is accepted
Thank you for the feedback.
All the suggestions are valuable for us. We will take them in consideration when working on the future versions of the RadGridView. I have updated your telerik points.
Feel free to write us if you have any questions.
All the best,
Jack
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
If a filter is set and the column then hidden by the user, there is no visual indication of an active filter. This can be especially confusing in combination with the SaveLayout()/ LoadLayout() feature.
- Explicit coding can be done on the UI to indicate if the column is filtered. Example: color the column when filtered.
**Make use fo cellformating event.
if (e.CellElement.ColumnInfo is GridViewDataColumn) |
{ |
for (int i = 0; i < rgvResult.MasterGridViewTemplate.FilterExpressions.Count; i++) |
{ |
for (int j = 0; j < rgvResult.MasterGridViewTemplate.FilterExpressions[i].Parameters.Count; j++) |
{ |
if (((GridViewDataColumn)e.CellElement.ColumnInfo).FieldName == |
rgvResult.MasterGridViewTemplate.FilterExpressions[i].FieldName) |
{ |
if (rgvResult.MasterGridViewTemplate.FilterExpressions[i].Parameters[j].Value != null) |
{ |
if (rgvResult.MasterGridViewTemplate.FilterExpressions[i].Predicates[0].Function != GridKnownFunction.NoFilter) |
{ |
if (!(e.CellElement is GridHeaderCellElement)) |
{ |
e.CellElement.DrawFill = true; |
e.CellElement.NumberOfColors = 1; |
ee.CellElement.BorderBottomColor = e.CellElement.BackColor = System.Drawing.Color.Beige; |
} |
} |
else |
{ |
if (!(e.CellElement is GridHeaderCellElement)) |
e.CellElement.DrawFill = false; |
} |
} |
else |
{ |
if (!(e.CellElement is GridHeaderCellElement)) |
e.CellElement.DrawFill = false; |
} |
} |
break; |
} |
} |
} |
///Event |
private void CallFormatCell(RadGridView rgvResult, CellFormattingEventArgs e) |
{ |
FormatCell(rgvResult, e); |
} |
Hope this helps till Telerik comes up with blink.
Regards
Pradeep
Regards
Erwin
Please do not hesitate to write us if you have any questions.
Greetings,
Jack
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
I go with Erwin's query and even had the same requirement in my application where in the user need to be indicated whether any filter is applied for any column. Infact as per my requirement, the user feels comfortable to see a colored funnel when a filter is applied and an empty funnel icon if its not applied.
Currently am using the latest version (2010 SP1) and could you please confirm whether you have included any attribute or event in gridview such that I can achieve this.
Please help me out on this.
Thanks
Krishnan N
Kind regards,
Jack
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.
You could color the header in cellFormatting event (for sorted/filtered scenario). Hope if that helps you though..
prad
The checkbox/boolean column filter is more intuitive in 2010Q1 where the checkbox is now not shown if no filter set.
But there is still room for improvement for the filter UI.
In my app, I have derived a grid control from the original grid which provies a context menu and button to clear all filters.
These controls are only enabled, if a filter is set, so the user has direct feedback on active filters.
Plus I always display the total amount of records in the datasource and the amount of visible records. This helped a lot in reducing support questions such as "I can't see my data anymore".
Regards
Erwin
Please, feel free to share your project with the community. I think it will be helpful and we will appreciate that. We will add a property which indicates whether filtering is applied on a column in one of our upcoming releases.
Best wishes,
Jack
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.
So because of this, and the fact that in our saved views we allow the user to filter down on any particular column, when this saved view data is loaded into the grid, it will be pre-filtered if you will. Therefore, the column filter is not colored or showing of a filter applied in any way, because of course from the grid's perspective there is no filter.
So what would be ideal is the following in order of importance
1. Ability to just set a flag on the column that visually indicates it is filtered (even if the user cannot see the filter... it's still a help)
2. At the bottom of the list, some button or other UI control to indicate the user can click and retrieve more values. This would trigger an even we could catch and then allow us to populate a complete list of values that we retrieved from the database. Then, we'd need a way to know if they had checked any of these "virtual" filters so that we could modify our saved view definition and pullback the new dataset that was inclusive of those values.
Hope you are following. I'm just describing the underlying problem and one possible solution. I'd be glad to discuss more in detail if needed. To end on a positive note, the user of the Telerik controls has had a huge impact on our product's usability and excitement in our company. So thanks,
Eric
Thank you for your feedback. We appreciate it and you have a point. I will discuss all possible scenarios with our developers and we will think how to improve our API to enable these features.
Kind regards,
Jack
the Telerik team
I am trying to implement a similar code for the ASP.Net grid, but here is no CellFormating event in the ASP version...
Any suggestion?
Regards,
M.R.
This forum concerns RadGridView for WinForms, while your question is related to RadGridView for ASP.NET AJAX. Please address your question to the appropriate forums, so you can get adequate answer.
All the best,
Stefan
the Telerik team
Hello :)
Now 5 years later ... are there any changes? My customer needs a signal that a specific column is filtered and needs a button like in the infragistics UI to clear all filters at once or clear one specific filter, as shown in the picture. How can I get this with the Telerik UI?
Thanks in advance.
Best regards, Matthias
Hi Matthias,
current Versions of the grid indicate filtered columns by changing the color of the filter icon. A clear-all button that serves at the same time as an indicator for a filter in any columns, you will have to implement yourself.
In my app I have wrapped the grid in a user control that consistently shows the number of records, number of filtered records and a clear all filter button that is enabled only if there are any filters active.
The grid exposes the needed events and properties to implement this logic exactly the way suitable for your users. Wrapping the grid saved me a few times while migrating the application through countless Telerik releases in the last 10 years. Required workarounds for bugs and glitches could often be implemented centrally in the wrapper.
Regards
Erwin
Hi Erwin,
many thanks for your fast reply.
I saw some suggestions in this forum and tried a bit myself, but I am not satisfied with my solutions. Is it possible that you can show me some code fragments that I understand which route to go?
I like the idea you described what you are using in your app :)
Best regards
Matthias
Hi Erwin,
many thanks for your fast reply.
In my app there are about 40 columns and the color of the filter icon could be overlooked very easy.
Therefore I like your idea that you are using in your app. Is it possible that you can show me some code fragments that I can see which route to take? I tried some suggestions from the forum and experiment myself, but the solution did not satisfy me.
Best regards
Matthias
Hi Matthias
Here are some code snippets that solve basic problems where the solution was not obvious to me. The code is based on help here in the forum and from Teleik Support.
Get Number of Visible Rows
The grid does not expose this directly, for grouped grids we have to traverse the children.
The number of available rows is best taken from the datasource.
private
static
long
getVisibleRows(GridViewChildRowCollection rows)
{
long
i = 0;
foreach
(GridViewRowInfo row
in
rows)
{
// if the grid is grouped, we have to recursively descend into child rows
if
(row
is
GridViewGroupRowInfo)
{
i += getVisibleRows(row.ChildRows);
continue
;
}
i += 1;
}
return
i;
}
/// <summary>
/// returns number of currently visible rows in the grid
/// </summary>
/// <param name="grid"></param>
/// <returns></returns>
public
static
long
GetVisibleRows(RadGridView grid)
{
return
getVisibleRows(grid.MasterTemplate.ChildRows);
}
Are Any Filters defined Are there Any hidden columns in the grid (Show all Columns / Column Chooser visual hints)
// any filters defined?
bool
anyFiltersDefined = grid.MasterTemplate.FilterDescriptors.Count > 0;
/// <summary>
/// true if there are hidden columns
/// </summary>
public
bool
HasHiddenColumns
{
get
{
foreach
(GridViewDataColumn c
in
grid.MasterTemplate.Columns)
{
if
(!c.IsVisible && c.VisibleInColumnChooser)
{
return
true
;
}
}
return
false
;
}
}
Event Handers to catch changes to column visibility and filter configuration
// register event handler for each column
foreach
(GridViewDataColumn column
in
this
.containedGridView.Columns)
{
column.PropertyChanged -=
this
.gridViewColumn_PropertyChanged;
column.PropertyChanged +=
this
.gridViewColumn_PropertyChanged;
}
private
void
gridViewColumn_PropertyChanged(
object
sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if
(e.PropertyName ==
"IsVisible"
)
{
// trigger your UI update logic here, a column visibility has changed
this
.UpdateMyButtons();
}
}
grid.FilterChanged +=
new
Telerik.WinControls.UI.GridViewCollectionChangedEventHandler(
this
.gridView_FilterChanged);
private
void
gridView_FilterChanged(
object
sender, Telerik.WinControls.UI.GridViewCollectionChangedEventArgs e)
{
// trigger your UI update logic here, filter config has changed
his
.UpdateMyButtons(
);
}
Regards
Erwin
Many thanks, especially for the hidden and grouped hint :)
This looks nice by the way.
Best regards,
Matthias
I am glad to see that you are exchanging some experience with the RadGridView in the forum.
@Erwin, I have also updated your Telerik points for your community effort.
@Matthias, note that RadGridView offers the FilterDescriptors collection which store all filters applied to the columns. You can clear the collection in order to clear all filters or remove just a single FilterDescriptor for a given column. Additional information about the filtering functionality is available in the following help article: https://docs.telerik.com/devtools/winforms/gridview/filtering/setting-filters-programmatically-(simple-descriptors)
I hope this information helps. If you have any additional questions, please let me know.
Regards,
Dess
Progress Telerik