Description:
Refer to the following XtraGrid documentation for more information on this feature:
WinForms Controls > Controls and Libraries > Data Grid > Conditional Formatting
GridOptionsMenu.ShowConditionalFormattingItem Property
WinForms Controls > Controls and Libraries > Tree List > Conditional Formatting
TreeListOptionsMenu.ShowConditionalFormattingItem
WinForms Controls > Controls and Libraries > Pivot Grid > Data Analysis > Conditional Formatting
PivotGridOptionsMenu.EnableFormatRulesMenu
Answer:
In general, accomplishing this task consists of several independent parts.
1. Enabling, saving and restoring GridFormatRule, TreeListFormatRule or PivotGridFormatRule objects using the standard XtraGrid, XtraTreeList, XtraPivotGrid approaches as per What is the best way to save and restore information just about Conditional Formatting rules in GridControl without using the RestoreLayoutFromXXX and SaveLayoutToXXX methods?
2. Integrating this solution in the GridListEditor, TreeListEditor or PivotGridListEditor (note that this editor requires a small adjustment as per the T348006 thread) using a ViewController as described in the Access Grid Control Properties help topic.
3. Serializing the control's formatting rules information, taking into account the fact that it uses a different mechanism for storing settings, which is based on the Application Model. In XAF, it is best to extend the ListView node with a string property that will hold a serialization representation of formatting rules. Refer to the How to: Extend the Application Model article for more details.
The two attached ViewController files (add them into YourSolutionName.Module.Win project) illustrate how these parts can be accomplished in XAF v15.1.7+ (you might be also required to add the WinForms Tree and Pivot Grid List Editor modules via the Application Designer or Module Designer to allow Visual Studio to automatically add required assembly references).
Thanks Dennis! Works like a charm!!!
How about creating a user interface to enable users to create their own ConditionalFormattingRules (without them knowing about the technicalities, of course)? That would be another huge improvement IMO!
Willem
Thanks for your feedback, Willem.
>>How about creating a user interface to enable users to create their own ConditionalFormattingRules
What about the existing "Manage Rules…" command as well as other items under the Conditional Formatting menu group shown in the screenshot above?
My suggested solution should work on the object level to create a consistent way of presenting information in any view, listviews as well as detailviews. With your solution users have to recreate the rules for all of their relevant listviews.
I immediately agree that your solution has a lot of beauty of its own, enabling users to create list-specific rules to format their information. And I know that - being a power user of my applications myself - i will strongly promote the use of this new function to my co-workers.
My suggested solution enables users to create their own - sometimes unique - formatting options e.g. to signal important situations for them, no matter where they happen to be in the application.
Thanks for your clarification, Willem. It seems that you are referring to something that was shown in my blog post: Making XAF Conditional Appearance more user-friendly. If so, our team is already aware of this suggestion and keeps it in mind. Thanks again for bringing this to our attention.
Yes Dennis, that's what i meant.
BTW in Q381881 you referred to that post, but the link is invalid nowadays.
Thanks for your confirmation.
I've updated the broken link accordingly.
@All:
I have slightly updated the original code. Take special note that starting with v15.1.7+ the loop below will not be necessary:
foreach(XafGridColumnWrapper item in gridListEditor.Columns) { item.Column.Name = item.Id; }
Perfect Guys! BTW: Has the treelist editor the same restirction? does it also need the column.name?
Hi Dennis - i just testet the demo - works perfect - but some rules are not restored? For example if i create an FormatConditionRuleDataBar (via Manage Rules) - and Close / reopen the view - this rule is not applied? If i go to the manage rules form - i see the rule is restored - and if i click OK - the rule is applied, but not so after opening the view?
I mean an 2 Color Scale - databar seems to work
Does not work for the treelist either. i changed GridFormatRuleCollection to IFormatRuleCollection - and did the same save/restore für the treelist rules. simple rules work - but not so databars / Icon sets and so on. The rules are stored - but somehow not applied?
Hello Noxe,
Thank you for taking the time to test this solution and sharing your thoughts with us!
>>Has the treelist editor the same restirction? does it also need the column.name?
This thread is devoted to XtraGrid and GridListEditor and I have not yet researched implementing the same feature for TreeListEditor and XtraTreeList and this requires additional research and time. I will update the community once this R&D is done, though I cannot promise a fast reply.
>> mean an 2 Color Scale - databar seems to work
I am going to research whether this ever worked in the original What is the best way to save and restore information just about Conditional Formatting rules in GridControl without using the RestoreLayoutFromXXX and SaveLayoutToXXX methods? sample in the first place. Then I will check out the XAF integration. I will update this thread once I have any news. Thanks.
Hi Dennis,
could you or the XtraGrid replicate the Problem?
Hi Noxe,
For now, I managed to get this working with TreeListEditor - see the attachment (I am going to further polish it and publish in my blog and here for everyone). Currently, I could not replicate the behavior you described above using v15.1.6 and 15.1.7: the description is a bit vague and I am probably using different steps. To be able to research this further, please submit a separate ticket and provide a step-by-step instructions or video using the code I posted above and our MainDemo.Win app. Thanks.
Hi Dennis,
I am setting this menu option by default and it is not taking effect. I do not see the additional menu, could I be doing something wrong here? This is in the latest version of 15.1.7
@Michael: I cannot replicate this behavior locally with v15.1.7 and the Controller code I posted above. Would you please submit a separate ticket and attach your problematic sample for review?
Denis, conditional formatting is really a cool feature that you should include out of the box on the next XAF release.
@bbirbo: I am happy to hear that you liked it. Our team will take your suggestion into account.
any update to support the pivotgrid
@Mohamed Al Zayani:
I've created a separate ticket on your behalf (T472136: Native conditional formatting rules for pivot grid). It has been placed in our processing queue and will be answered shortly.
is possible to do the same in web? or use settings from windows grid in web grid?
Yes, absolutely.
No, because these controls are incompatible.