Bug Report T622196
Visible to All Users

Template methods don't replace previously set values

created 7 years ago

Hello,

After updating to the latest version of DevExtreme I have an issue with setting of cell templates using CellTemplate() method. In my solution I have the common place where I set default cell template for the columns, and then it's possible to replace it by some custom template (it means that I can call CellTemplate() method more then one time). It worked perfect before but now I always see the first template I was set into the column - it seems now CellTemplate doesn't replace templates.
I have attached screenshot where you can see that the "column0" has 2 templates and for the "column1" I'm trying to set the second one template too.

Is it a bug or new behavior of the CellTemplate method (in this case how can I replace previous cell template in the column)?
Thanks!

Answers approved by DevExpress Support

created 7 years ago (modified 7 years ago)

We have fixed the issue described in this ticket and will include the fix in our next maintenance update. To apply this solution before the official update, request a hotfix by clicking the corresponding link for product versions you require.

Note: Hotfixes may be unavailable for beta versions and updates that are about to be released.

    created 7 years ago

    Hi,

    1. The internal Templates property is a dictionary. So, its content is not ordered and we cannot grantee that the latest template will be used.

    2)  Normally, the CellTemplate method is used to assign only a single template. If you wish to implement conditional template assignment, it is possible to assign a custom function to the cellTemplate and calculate the require template in the context of this function. For example:

    JavaScript
    function getTemplate(e) { var someCondition = true; if (someCondition) return "<div>123</div>" else return "<div>456</div>" }
    C#
    columns.AddFor(m => m.ShipCity).CellTemplate(new JS("getTemplate()"));

    Please let me know if your scenario is different.

    Thanks,
    Alessandro

      Comments (2)

        Hi Alessandro,

        thank you for the answer. Unfortunately, it's not the solution for me, so I need to refactor my application to make it possible to use this method only once… But why this behavior has been changed and I don't understand why it stores all set of templates if it uses the only one item from this dictionary? It looks like as a bug. Just confirm that it's new behavior and I don't need to wait new changes, so I'll start refactor of my application.

        Thanks!

        Alessandro (DevExpress Support) 7 years ago

          Hi,

          We are working on your problem and need some additional time to research it in greater detail. We will let you know of our progress once we have any results. I hope you will excuse any delay that may arise.

          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.