Bug Report T879946
Visible to All Users

DataGrid - A lookup column doesn't display a value for a new row with "cell" editing mode if calculateDisplayValue is defined

created 5 years ago (modified 5 years ago)

Hey,

I have a column config like this:

HTML
<dxi-column dataField="objectId" caption="Object" calculateDisplayValue="object.displayText"> <dxo-lookup [dataSource]="objects" valueExpr="id" displayExpr="displayText" [allowClearing]="true"> </dxo-lookup> </dxi-column>

The data source of the DataGrid looks like this:

TypeScript
[ { "id": 123, "objectId": 321, "object": { "id": 321, "displayText": "example" } }, ... ]

And the data source of the lookup:

TypeScript
[ { "id": 321, "displayText": "example" }, ... ]

Displaying the column works fine for existing rows, i.e. it shows object.displayText property. But when a new row is inserted (I am using "cell" editing mode) and a value for the lookup column is selected, then the cell will be empty afterwards.

If I remove the calculateDisplayValue option, then it works as expected for new rows as well, but then of course all of the lookup values are being loaded in the first place.

Is there any way to solve this without the need to set the nested object manually for new rows after selecting a value from the lookup?

Thanks!

Show previous comments (7)
Artem (DevExpress Support) 5 years ago

    Hi Jan,

    Thank you for the update. I checked this example and see that a lookup column has a caching mechanism that works when values are strings. The behavior is indeed inconsistent and we need more time to research it. Please bear with us.

    Note that the State object is not created in both cases after inserting a new row. So, I would still recommend you use setCellValue if you need to apply changes to the State column in your real application.

      Hey Artem,

      Thanks for the update!

      Actually, I don't want to set the State object, thus I set valueExpr="ID" in the lookup. And in the column I have dataField="StateID" … so in this example it actually does what I need, a new entry gets the StateID attribute set correctly and the selected state is shown in the cell … see this example again: https://codesandbox.io/s/u0b4s

      Thanks,
      Jan.

      Artem (DevExpress Support) 5 years ago

        Thank you for the clarification. We'll make an update here once we have any news.

        Answers approved by DevExpress Support

        created 5 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.

          Comments (3)

            Hey Artem,

            I see this issue has been marked as fixed. Could you please let me know in which version it should be fixed and what exactly the fix means, i.e. will it then work for non-string values as well?

            I recently updated to 20.1.3 but I did not see a change in the behavior.

            Thanks,
            Jan.

            DevExpress Support Team 5 years ago

              Hi Jan,

              This issue is fixed in the next minor version (20.1.4). The fix should work for non-string values.

              Let me know if you have further questions.

                Hey Lex,

                Thanks for your clarification!

                Best,
                Jan.

                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.