Ticket Q581942
Visible to All Users
Duplicate

We have closed this ticket because another page addresses its subject:

ConditionalAppearance - How do I customize the item caption text based on a certain condition

Dynamic display value for field

created 11 years ago

Hi,

I have the case when I need to change the display of one field when something changes on the detailView.
So consider having a "Value" field that has to change name every time when the selection in a dropdown changes.
Is there a way to accomplish this?

To make it easier, I've attached a sample in which you can see exactly what I mean.

  1. Start the application
  2. Go to SystemSettings ListView
  3. New System Setting
  4. Select in Setting dropdown "Default order type" -> the value field should have "Default order type" text instead of "Value"
  5. Select in Setting dropdown "Default receipt type" -> the value field should have "Default receipt type" text instead of "Value"

Thanks,
Radu

Answers approved by DevExpress Support

created 11 years ago (modified 11 years ago)

Hello Radu,
In the current version, I can only advise you to implement a ViewController that will handle the View.ObjectSpace.ObjectChanged event and update the layout item's caption manually.
The links given in the answer to Change the label of a Property at run time contain some example code on how to implement this task on the Web. I hope you find this information helpful.

    Show previous comments (1)
    Dennis Garavsky (DevExpress) 11 years ago

      Hello Radu,
      As far as I understand your difficulty, you cannot rely on the dynamic caption when writing static scripts, correct? I thought that you could use the correct dynamic value in the script itself depending on the situation and it should operate correctly. It will be harder to maintain such a script, but it should normally work as expected.
      If you cannot do this, then you can use an invariant control identifier in your script. You can determine this identifier by enabling Diagnostic Action and then using its EasyTest Control diagnostic info for a required XAF View.

        Hi Dennis,
        On further investigation I managed to use the dynamic captions by also setting caption field of the view item, so both of these on the this.View.ObjectSpace.ObjectChanged event:
        // this for the display value to be changed
        ((System.Web.UI.WebControls.Literal)(((DevExpress.ExpressApp.Web.Layout.LayoutItemTemplateContainer)((System.Web.UI.Control)viewItem.Control).NamingContainer).CaptionControl.Controls[0])).Text = caption;
        // this for the easyTest to be able to use the new caption
        viewItem.Caption = caption;
        Maybe someone else will also find this usefull.
        Radu

        Dennis Garavsky (DevExpress) 11 years ago

          Thanks for sharing your solution with the community.

          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.