hi guys,
I've read a lot of question about changing the caption of BO members during runtime but I didn't find
a proper solution for my situation supporting both windows and web, which I think is quite common.
I've a detailview with a lookup for products. Each product can have several different properties. If the user selects a product, I want to
retrieve the related properties for which I placed 5 hardcoded editors on my detailview with corresponding captions.
These captions needs to be changed everytime the user selectes another product.
I know I can change captions of detailviewitems for windows using the layoutmanager. This works, but for web, if I change the caption in code
the caption won't be refreshed at the current postback but at the next one??
Am I doing something wrong here?
(see sample)
BTW: can I solve this scenario by using a non-agnostic controller?
Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.
Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.
almost forgot.
here are the steps to reproduce my scenario:
Hello Arjan,
Please accept our apologies for the delay in responding. We couldn't find an immediate answer or resolution. Please bear with us. We will inform you as soon as an answer is found.
Thanks,
Michael.
Hello Arjan,
Your approach does not work because the detail view layout is created when controls are created. So, subsequent changes do not affect the layout. You can accomplish your task by modifying web controls using the following controller.
public partial class dvOrder : ViewController { public dvOrder() { InitializeComponent(); RegisterActions(components); TargetObjectType = typeof(IOrder); TargetViewType = ViewType.DetailView; } protected override void OnActivated() { base.OnActivated(); this.View.ObjectSpace.ObjectChanged += new EventHandler<ObjectChangedEventArgs>(ObjectSpace_ObjectChanged); } void ObjectSpace_ObjectChanged(object sender, ObjectChangedEventArgs e) { var obj = this.View.CurrentObject as IOrder; if (obj != null) { if (e.PropertyName == "Product" && obj.Product != null) { SetItemCaption(((DetailView)this.View).FindItem("Prop1"), obj.Product.Properties[0].Code); SetItemCaption(((DetailView)this.View).FindItem("Prop2"), obj.Product.Properties[1].Code); } } } private void SetItemCaption(ViewItem viewItem, string caption) { ((System.Web.UI.WebControls.Literal)(((DevExpress.ExpressApp.Web.Layout.LayoutItemTemplateContainer)((System.Web.UI.Control)viewItem.Control).NamingContainer).CaptionControl.Controls[0])).Text = caption; } }
I am afraid there is no platform-independent solution.
Thanks,
Michael.