serenity-is / Serenity

Business Apps Made Simple with Asp.Net Core MVC / TypeScript
https://serenity.is
MIT License
2.57k stars 796 forks source link

id parameter in call to validateEntity from GridEditorBase is set to null even though an existing item in the grid was selected #6668

Closed DGoertzen closed 1 year ago

DGoertzen commented 1 year ago

What happened?

After editing an item in a "detail list" created by using GridEditorBase (similar to the Order detail at https://demo.serenity.is/Northwind/Order#edit/11077 ) , validateEntity is called with id == null. This causes an additional item to be put into the detail list, rather than replacing the item that was edited. After debugging, I found that the function save in GridEditorBase calls:

var id = this.id(row);

id is returned as null, even though this is a row that is being edited, not created. Here is a screen shot of from visual studio showing that, after executing that call above, row is valid, but id is not defined

image

I checked the html and it looks fine.

image

What did you expect to happen?

I expected that, when the function validateEntity is called, that id would be set to a valid number rather than null when a existing item is selected in a detail list.

How to reproduce?

The behavior seems to be consistent for all detail list editors that I have implemented. I did not think it had this behavior in the past and am wondering if it is do to a more recent Serenity release, or I've screwed something up in my development environment, or I've done something stupid...

What Serenity Nuget Versions are you seeing the problem on? (separated by comma)

6.4.10

Relevant log output

No response

Serene template version

No response

Sergen version

No response

Code editor

No response

Operating System

Windows 11

Node.js version

No response

TypeScript version

No response

Database type and version

No response

On which device do you see the problem?

No response

On which operating system do you see the problem?

No response

On which browsers do you see the problem?

No response

On what version of the browsers do you see the problem?

No response

Additional information

No response

volkanceylan commented 1 year ago

I don't see this in Order Details editor, so probably you have something different in your editor.

volkanceylan commented 1 year ago

Check if you have a getIdProperty() method in your grid editor. You should not have that.

DGoertzen commented 1 year ago

You are a genius. Thanks. I did have a getIdProperty() in the GridEditorDialog class. Removing that fixed the problem. Now that I knew what to look for, I even found that you had troubleshooting on it already - https://github.com/serenity-is/docs/blob/a89a776a0136966926bbc5df3176d4c4dad86cc7/faq/troubleshooting.md#masterdetail-editing

Sorry I missed that. Thanks for your great help!