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

RadGridView filter behaviour when modifying cell contents

2 Answers 39 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ben
Top achievements
Rank 1
Ben asked on 23 Jan 2012, 02:49 AM
Hi all,

This is a somewhat exploratory question as to how I could go about implementing a behaviour that I have been requested to implement. Apologies for my hyper-verbosity below :-).

The short version:
How do I stop a filter being applied when the value in a cell changes to no longer match the filter?

The requested behaviour:
(For some context) - I am currently implementing a mechanism whereby a user can right click on an editable column in the datagrid and choose to apply the current value to all currently visible (given the filter conditions of the grid) cells of the same column via a context menu. I have managed to get this feature working (at least in an initial version) and am reasonably confident that I will be able to develop it into the foundation of my project. 

< ... breathes in  ... >

The issue I am having relates to the effect of applying a filter to the same column that I am editing, and as such is not directly related to the above functionality. When a filter is applied to a column, editing a value to one which no longer matches the filter specified causes the row of the grid to be hidden when the user looses focus from the cell. While this logically makes sense to me as a developer in that the filter descriptors and the displayed data remain consistent. To the user, it appears that the data they were just editing has just disappeared (maybe forever). The ensuing panicked call to the support desk is one thing that I am trying to avoid. Also the ability to change one of the values, then apply that value to all other visible cells of the same column (as mentioned above) without this action causing said rows to be removed from the list of visible rows.

This behaviour can be seen in something like Excel 2010, where a filter can be applied to one or more columns, however the filter is not updated when the values in the columns change, unless the user specifically re-applies said filter.

Considered Approaches:
Here are a couple of approaches that I have already considered:
  1. Prevent Filtering on affected columns: Possibly the easiest solution to this issue would be to prevent (disable) filtering on columns where the value can be set via a context menu option. However, the ability to filter these columns is a desirable feature of the application, I would rather not remove the functionality unless it is necessary.
  2. Disable the context menu if a filter is applied: This would be a bit better than the last option, in that it would allow both features, just not at the same time. The problem here is how to inform the user (in an unobtrusive manner) that the ability to set the value is disabled because they have applied some sort of filter to this column and that removing that filter will allow them to perform the update that they want to. The catch here is that the filter they applied will be restricting the results to those that they want to update, removing it will likely change that result set ... catch 22.
  3. Automatically include the updated value in the filter descriptors for that column: This is my current best candidate although it has some limitations. This option would ensure that the new value would not cause the column to be removed from the set of visible columns. However, including another value in the filter could have unforeseen consequences (for example if 90% of the rows had the value of "2" and the filter was set to include only items which are NOT equal to "2". Setting the remaining values to "2" would result in an invalid filter (all values = "2" AND != "2" ... none). That is a fairly simple example, but they could be infinitely more complicated). Alternatively, even if the resulting filter was valid, it could result in the inclusion of the other 90% of the data, resulting in the row that you were editing being lost in the sea of data and the user being "surprised" by the sudden unexpected flood of information (and we all know there is nothing more dangerous than a surprised user).
  4. Prevent the modification of a value from having the current filter applied: This approach most closely emulates Excel 2010. However I have a few issues with it. How would the user know that the results shown in the grid no longer match the specified filters? (Could be done by changing the filter icon, but that is blowing the scope of this change out a bit). Secondly, how would someone go about doing this? I have been thinking about how to achieve this for a couple of days with no joy.

Any suggestions or comments, particularly on how to implement point 4 (above) would be greatly appreciated.

Regards,
    Mark
 

2 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 23 Jan 2012, 09:41 AM
Hi,

The only possible approach I can think of would be to filter the data before it goes to RadGridView, for example using LINQ or using RadDataFilter. RadGridView will not perform any filtering. By extracting the filtering logic out-side of RadGridView you will be able to fully control it and decide when to "re-apply" the filter like in Excel.

Alternatively, you can use RowStyleSelector to paint certain rows in certain colors and thus convey filtering information to the end user through colors, instead of through real data filtering.

But I am really afraid that RadGridView cannot be both filtered and left in an inconsistent state. Unfortunately we don't have a mechanism for this and I don't think that it can be easily achieved.

All the best,
Ross
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Ben
Top achievements
Rank 1
answered on 24 Jan 2012, 12:26 AM
Hi Ross,

Thanks for the reply. It's good to know that I wasn't missing something easy and obvious :-). I will have to look further into it to see if there are any alternative ways to accomplish what I need to do. 

I think extracting the filtering logic out as you suggested in the first paragraph is probably the most likely scenario that I will be trying, although the associated changes could have a significant ripple effect with the way things work. Will have to be cautious about it.

Regards,
     Mark
Tags
GridView
Asked by
Ben
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Ben
Top achievements
Rank 1
Share this question
or