eXpandFramework / eXpand

DevExpress XAF (eXpressApp) extension framework. 𝗹𝗶𝗻𝗸𝗲𝗱𝗶𝗻.𝗲𝘅𝗽𝗮𝗻𝗱𝗳𝗿𝗮𝗺𝗲𝘄𝗼𝗿𝗸.𝗰𝗼𝗺, 𝘆𝗼𝘂𝘁𝘂𝗯𝗲.𝗲𝘅𝗽𝗮𝗻𝗱𝗳𝗿𝗮𝗺𝗲𝘄𝗼𝗿𝗸.𝗰𝗼𝗺 and 𝘁𝘄𝗶𝘁𝘁𝗲𝗿 @𝗲𝘅𝗽𝗮𝗻𝗱𝗳𝗿𝗮𝗺𝗲𝘄𝗼𝗿𝗸 and or simply 𝗦𝘁𝗮𝗿/𝘄𝗮𝘁𝗰𝗵 this repository and get notified from 𝗚𝗶𝘁𝗛𝘂𝗯
http://expand.expandframework.com
Microsoft Public License
222 stars 115 forks source link

How to run ModelMapper #548

Closed txt2203 closed 4 years ago

txt2203 commented 5 years ago

Question I created DXapplication1 to test ModelMapper. Installed from Nuget and added module. And use XPand ModelDesigner to setup ModelMapper-Mappercontexts-Default-GridView. For my table1ListView, there has Default of ModelMapper and I not set any more . I think it uses setting from Default setting above. I run project. No setting applied. EnableAppearanceEvenRow and EnableAppearanceOddRow not ran. Please advise if there is lack of additional setting. Thanks and best regards, Truong

Additional context Add any other context or screenshots about the feature request here. image

image

image

image

apobekiaris commented 5 years ago

Contexts are not impmented yet you can only apply the configuration to the parent ListView

txt2203 commented 5 years ago

Could you please supply an example so I can learn ?

apobekiaris commented 5 years ago

the Customer_Receipts_ListView in XvideoRental demo has configured column and gridview options https://github.com/eXpandFramework/eXpand/blob/2518300e8e660014bc6f0b4ad2feb7e0628c192b/Demos/XVideoRental/XVideoRental.Module.Win/Model.DesignedDiffs.xafml#L764-L794

note that the module has also a great number of tests you can consult https://github.com/eXpandFramework/DevExpress.XAF/tree/master/src/Tests/ModelMapper

apobekiaris commented 5 years ago

see also the docs https://github.com/eXpandFramework/DevExpress.XAF/tree/master/src/Modules/ModelMapper

txt2203 commented 5 years ago

Tests are complex to me to understand. When in 19.1.3, I set ModelAdapterContext config once and then GridView setting applied OK for all GridView in my project (except custom viewcontroller). However, after up 19.1.6, ModelAdapterContext was replaced by ModelMapper, I lost all old settings. I set ModelMapper config like ModelAdapterContext but nothing applied when run. My table is only simple table for test. So how to set once time and then almost GridView run with that Default settings ?

apobekiaris commented 5 years ago

as I said the context functionality in the ME is not yet implemented, however

  1. you can code it deriving from ModelNodesGeneratorUpdater<ModelViewsNodesGenerator>
  2. if u still want to go for ME you can try with ModelViewInheritanceModule where you can add a ModelMergedDifferencesAttribute to your BaseObject resulting to a link between it listview and all derived objects listviews. Then you can use the ME to modify the BaseObject_ListView..GridViewOptions node and this will be inherited to all linked listviews.
apobekiaris commented 5 years ago

I haven't tried my second suggestion let me know if it works if you try it please. However it looks like we have a very powerful way to create shared model configuration with the ModelViewInheritance module. It makes me think that implementing contexts for options is not in need anymore and only duplicates the same action.

txt2203 commented 5 years ago

I tried 2nd suggestion and although I have to create MergedDifferences per View to link to BaseObject , but then it run OK when I change BaseObject_ListView.GridViewOptions ( Attached pic ). However, each table has usually 3 views (List,Lookup,...) so if have to set MergedDifferences for each view is not comfortable for projects ~100 tables. image

apobekiaris commented 5 years ago

try this in your module.cs

public override void AddGeneratorUpdaters(ModelNodesGeneratorUpdaters updaters) {
            updaters.Add(new MergedDifferenceUpdater());

        }

and the updater will look like

    public class MergedDifferenceUpdater : ModelNodesGeneratorUpdater<MergedDifferencesGenerator>{
        public override void UpdateNode(ModelNode node){
            var modelMergedDifference = ((IModelMergedDifferences) node).AddNode<IModelMergedDifference>();
            modelMergedDifference.View = node.Application.Views["Common_ListView"].AsObjectView;
        }
    }

the updater will generate rules for all listviews, feel free to filter it to your needs

txt2203 commented 5 years ago

Thanks for support. I changed "Common_ListView" to "XPLiteObject_ListView" because almost use baseclass XPLiteObject. But "XPLiteObject_ListView" is grid so it affected to only Views based on Grids. For views using editor Treelist, how to setup ?

apobekiaris commented 5 years ago

i do not get where the problem with TreelistEditor the process should be the same

expand commented 4 years ago

Closing issue for age. Feel free to reopen it at any time.

.Thank you for your contribution.