Ticket Q474184
Visible to All Users
Duplicate

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

How to refresh View appearance after making changes to the Application Model in code

Change Editor Of View At Runtime

created 12 years ago

I have created one action that
toggles the Editor For View (ASPxGridListEditor and ASPxTreeListEditor) but on click on this action
change is not reflected properly. It only get reflected after the first
postback on page. I am assuming this as Edit
Action is not available but it gets available after first postback. I have attached demo project.

<para class="MsoNormal"> Steps to reproduce: Create
one record, Navigate
on listview, Click
on Toggle Editor (Now Edit Action In Grid/Treelist gets invisible).
</para>

Comments (1)
DevExpress Support Team 12 years ago

    We are working on your issue and will answer you as soon as possible. We apologize for the delay.

    Answers approved by DevExpress Support

    created 12 years ago (modified 7 years ago)

    Hello,

    UPDATED:
    Starting with v16.2.4, you can implement an Action that would customize required options in the Application Model and recreate the View controls accordingly, as described at Task-Based Help > How to: Apply Application Model Changes to the Current View Immediately .
    ===============

    >>

    C#
    private void Toggle_Editor() { if (View.Model.EditorType == typeof(ASPxGridListEditor)) { View.Model.EditorType = typeof(ASPxTreeListEditor); } else View.Model.EditorType = typeof(ASPxGridListEditor); View.LoadModel(); //View.CreateControls(); }

    <<
    Such serious changes require a post back on the Web. So, you need to customize your Action as follows:

    XML
    <ActionDesign> <Actions> <Action Id="ToggleEditor" IsPostBackRequired="True" /> </Actions> </ActionDesign>

    It is also better to recreate the whole View, because the View.LoadModel method does not guarantee that all controllers will be activated:

    C#
    Frame.SetView(Application.CreateListView(View.Model, Application.CreateCollectionSource(Application.CreateObjectSpace(), View.CollectionSource.ObjectTypeInfo.Type, View.Id, View.CollectionSource.IsServerMode, View.CollectionSource.Mode), View.IsRoot));

    Finally, you can use the built-in ViewVariants module that helps accomplish such tasks easier.
    Let me know if I can assist you further.

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

        Thanks for the update. I have not received any errors while testing the suggested solution. Probably, there is some misunderstanding of your requirements on my side. So, I would like to ask you to illustrate the current and expected behavior with screenshots or a small video.

          Hi Dennis,
          It doesn't gives any runtime or design time error. Basically, as originally posted I have observed that Edit Action get invisible on click of ToggleEditor Action. It seems like the page is not loading properly.
          Steps are still the same
          > Create one record,
          > Navigate on listview
          > Click on Toggle Editor (Now Edit Action In Grid/Treelist gets invisible).
          Attached screenshots for further understanding.

          Dennis Garavsky (DevExpress) 12 years ago

            I have updated my original answer.

            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.