- Create a new Radzen application.
- Create a new SQL Server data source and press Create sample schema. Generate CRUD pages from the data source.
- Enable security and generate security pages.
- Delete the Edit Order Detail and Order Details pages.
- Open the Edit Order page.
- Select the Form component and delete teh
User Name
field. - Add a DataGrid component and bind it to the
getOrderDetails
data source method with$filter
parameter set toOrderId eq ${parameters.Id}
and$expand
set toProduct
. - Autogenerate the columns.
- Set the Template of the Product Id column to
${data.Product?.ProductName}
. Set the Title toProduct
. - Check the AllowAdd DataGrid property.
- Check the AllowDelete DataGrid property.
- Handle the DataGrid Add event and open Add Order Detail as a dialog with parameter
OrderId
set to${parameters.Id}
- Handle the DataGrid Delete event and invoke the
deleteOrderDetail
method with parameterId
set to${event.Id}
.
- Select the Form component and delete teh
- Open Add Order Detail page.
- Select the form component and remove the
Order
field. - Go to the Events tab in the property grid. Replace the
${event}
value of thesubmit
event parameter withObject.assign(${event}, {OrderId: ${parameters.OrderId}})
. - Add a Then action that navigates back.
- Select the form component and remove the
- Open the Add Order page, select the form component and remove the
User Name
field. - Open the Edit Order page, select the form component and remove the
User Name
field. - Run. Open an order and add order detail. Stop to customize the generated code.
- Open generated application with your favorite edtor and add a new file called
OrdersController.custom.cs
next toOrdersController.cs
:using System.Security.Claims; using [APPLICATION_NAME].Models.[DATASOURCE_NAME]; namespace [APPLICATION_NAME].Controllers.[DATASOURCE_NAME] { public partial class OrdersController { partial void OnOrderCreated(Order item) { item.UserName = this.HttpContext.User.FindFirst(ClaimTypes.Name).Value; } } }
- Run application