I'm trying to implement something where when a numeric field changes, it automatically enters a value in another property. I've been having problems doing this as I learn more about Radzen so have stripped it back to a minimum to try and find the problem and cannot overcome this issue.
I have a simple entity and have created a test project. On either an Add or Edit page, I add a change event to a numeric input field.
I did the Radzen update today (after putting it off a few days) and this problem has reared it's head again. If I don't use the TValue attribute I get this error:
dotnet: Pages\EditFinish.razor(57,128): error CS1503: Argument 2: cannot convert from 'method group' to 'EventCallback' [C:\Code\SuttonPokerResults\server\SuttonPokerResults.csproj]
obj\Debug\netcoreapp3.1\Razor\Pages\EditFinish.razor.g.cs(155,174): error CS1662: Cannot convert lambda expression to intended delegate type because some of the return types in the block are not implicitly convertible to the delegate return type [C:\Code\SuttonPokerResults\server\SuttonPokerResults.csproj]
If I use the TValue attribute (as per the previous fix) I now get:
dotnet: Pages\EditFinish.razor(57,128): error CS0123: No overload for 'EditFinishComponent.PositionChange(decimal?)' matches delegate 'Func<int, Task>' [C:\Code\SuttonPokerResults\server\SuttonPokerResults.csproj]
obj\Debug\netcoreapp3.1\Razor\Pages\EditFinish.razor.g.cs(155,174): error CS1662: Cannot convert lambda expression to intended delegate type because some of the return types in the block are not implicitly convertible to the delegate return type [C:\Code\SuttonPokerResults\server\SuttonPokerResults.csproj]
Position is definitely an int, I don't know why it's referring to a decimal? Any pointers?
@Paul_Pitchford we will have to reproduce this at our end. Send us the application to info@radzen.com. Delete the server\bin and server\obj directories to keep the file size small.
BTW did you update this page in any way before or after the update? You can check in source control if there are any differences in the JSON file (should be edit-finish.json).
Yes the file has changed but I was going to address that in another thread but I'll quickly mention it here. When I had the templating issue on the dropdowns for displaying multiple columns you gave me this code:
${((data as Player).Forename)} ${((data as Player).Surname)}
This no longer works. So, I had modified the template to at least make it work and then I was going to come back to you on that issue.
Is there a fix for the above error? It's the change event of a text box contained in the edit template of a nested grid template. So a few levels nested - if that makes a difference.
We cannot reproduce this error and don't know if there is a fix for it. This error happens when the TValue type does not match the argument of the event handler. Then the C# compiler cannot infer the right type.
I wonder if there's an opportunity to simplify how RadZen handles page properties and infers types... What if we were required to explicitly define page properties and set their types instead of relying on the Set Property action in addition to other ways RadZen magically adds properties to pages. Would this not make things a bit easier when inferring types? Like if I had to define a collection property on the page and set the item type property to Inventory.ShipmentItemsDetail Then the grid data context would know the field property types from the model.
For example, in page built from nested grid wizard, the data property of the nested grid is set to ${rzNwModelsInventoryShipment.ShipmentItems}
I have no idea where that property came from and no way to change it's type. There isn't even a Set Property action that defines it so I assume it's generated by the execute C# action which populates the a collection property of the master. Could we not explicitly define that collection property on the Page and then have control over it's type?
I'm sure there are levels of complexity that I don't understand - it just seems that context, page properties and inferring types has a lot of hidden magic that can be limiting and actually fowl things up too easily.