-
Maybe it's possible to modify the model on Controller.Update model method ? (can't find any sample how to do that)
Or simply update the template's size property before it's assigned ?
1 Solution
It seems that this attribute does not work any longer. We will update our documentation. To accomplish this task, you can update the Model via the controller by assigning the Width and Height properties value of the IModelTemplateWin.FormStates["viewID"] model node as it is shown in the following code snippet:
[C#]((IModelTemplateWin)Application.Model.Templates[typeof(DevExpress.ExpressApp.Win.Templates.LookupControlTemplate).FullName]).FormStates["YOUR_OBJECT_LookupListView"].Width = "1000";
-
Posted by: Martin D.
Well, can't tell that I get the results expected
Take a look .
The template isn't there :|
-
Please use the code I provided earlier and do not forget to replace the "YOUR_OBJECT_LookupListView" string with a real lookup list view ID. Let me know if this helps.
-
No, it does not.
Gives a null reference exception at the index. Seems to me that it cant find any lookupview templates in the model
Thats why I listed the contents, and it only has 4 temps.
Tried with a new solution, same thing -
The Model.Templates and FormStates nodes are null because there is no any customization for this kind of template. In this case, I suggest that you manually add corresponding customization directly into the Model.xafml file. To get the valid xml, you can open a required lookup editor and resize it as you wish. The customization will be written to the Model.User.xafml file after you close the application. After you customize the lookup window size, open ModelEditor from the application and merge generated differences into the Model.xafml file using the Merge Differences button. This approach allows you to set the default size of the window, and it will not be lost if you remove the user differences for the model. If you set size this way, it will be possible to customize size at runtime. Using the code I suggested previously makes the runtime customization impossible. Hope this will help you.
-
I would like to stick to the "update from code" and find out why the template is not in the model.
Maybe I can Add it from code ? -
Yes, you can add these nodes from code, but in this case your user will not be able to customize the window size.
To add the nodes, you can use the following code:
string templateName = typeof(DevExpress.ExpressApp.Win.Templates.LookupControlTemplate).FullName; string lookupListViewID = "YOUR_OBJECT_LookupListView"; DevExpress.ExpressApp.Model.IModelTemplate templateModel = Application.Model.Templates[templateName]; if(templateModel == null) { templateModel = Application.Model.Templates.AddNode<DevExpress.ExpressApp.Model.IModelTemplate>(templateName); } DevExpress.ExpressApp.Model.IModelFormState formState = ((IModelTemplateWin)templateModel).FormStates[lookupListViewID]; if(formState == null) { formState = ((IModelTemplateWin)templateModel).FormStates.AddNode<DevExpress.ExpressApp.Model.IModelFormState>(lookupListViewID); } formState.Width = "1000";This code works fine in my tests. Do not hesitate to contact us in case of any further difficulties. -
Ok. this one works :)
But as You said, it overrides any user customization's done. -
In this case, use the Model differences the way I described earlier.
Is your intention to post an answer to your own question?
- If so, then proceed.
- If you simply wanted to post additional information, ask for further clarification, or to just say "Thanks!", please click Leave a Comment.
- If you wish to edit your original question, please use the Edit button in the Toolbox at the top right corner of that entry.
Facebook
Twitter
Google+