I would like to pass a defined piece of data in when I add a new row in a hierarchical Blazor grid. in the example below, I have a hierarchy of Agency > District > School. When I add a new school within a district, I would like to pass the District ID so that the user does not have to select it or type it in.
I have a district ID column in the schools grid, but (a) it would be better if the user did not see this and (b) when I click "Add school" that field is always passed as empty. Is there any way to pass the
districtSchools.Dist.DISTRICT_ID
variable when I add a row?
<TelerikGrid Data="@Agencies" Sortable="true" Reorderable="true" OnUpdate="@UpdateHandlerAgency">
<DetailTemplate Context="granteeAgency">
@{
var leadAgency = granteeAgency as Agency;
<TelerikGrid Data="leadAgency.Districts" OnUpdate="@UpdateHandlerDistrict" OnRowRender="@OnRowRenderHandlerDistrict">
<GridColumns>
<GridColumn Field="@(nameof(District.Dist.DistrictName))" Editable="false">
<Template>
@((context as District).Dist.DistrictName.ToString())
</Template>
</GridColumn>
<GridColumn Field="@(nameof(District.DistAlloc))">
<Template>
@((context as District).DistAlloc.ToString("C"))
</Template>
</GridColumn>
<GridCommandColumn>
<GridCommandButton Command="Edit" Icon="edit">Edit</GridCommandButton>
<GridCommandButton Command="Save" Icon="save" ShowInEdit="true">Update</GridCommandButton>
<GridCommandButton Command="Cancel" Icon="cancel" ShowInEdit="true">Cancel</GridCommandButton>
</GridCommandColumn>
</GridColumns>
<DetailTemplate Context="districtSchools">
<TelerikGrid Data="districtSchools.Schools" OnCreate="@CreateHandlerSchool" OnDelete="@DeleteHandlerSchool" OnUpdate="@UpdateHandlerSchool" OnRowRender="@OnRowRenderHandlerSchool">
<GridToolBar>
<GridCommandButton Command="Add" Icon="add">Add School</GridCommandButton>
</GridToolBar>
<GridColumns>
<GridColumn Field="@(nameof(School.SchoolName))">
<Template>
@((context as School).SchoolName.ToString())
</Template>
</GridColumn>
<GridColumn Field="@(nameof(School.SchoolAlloc))">
<Template>
@((context as School).SchoolAlloc.ToString("C"))
</Template>
</GridColumn>
<GridColumn Field="" Visible="true">
<Template>
@districtSchools.Dist.DISTRICT_ID
</Template>
<EditorTemplate>
@districtSchools.Dist.DISTRICT_ID
</EditorTemplate>
</GridColumn>
<GridCommandColumn>
<GridCommandButton Command="Edit" Icon="edit">Edit</GridCommandButton>
<GridCommandButton Command="Save" Icon="save" ShowInEdit="true">Update</GridCommandButton>
<GridCommandButton Command="Delete" Icon="delete">Delete</GridCommandButton>
<GridCommandButton Command="Cancel" Icon="cancel" ShowInEdit="true">Cancel</GridCommandButton>
</GridCommandColumn>
</GridColumns>
</TelerikGrid>
</DetailTemplate>
</TelerikGrid>
}
</DetailTemplate>
<GridColumns>
<GridColumn Field="@(nameof(Agency.AgencyName))" Editable="false">
<Template>
@((context as Agency).AgencyName.ToString())
</Template>
</GridColumn>
<GridColumn Field="@(nameof(Agency.AgencyAlloc))">
<Template>
@((context as Agency).AgencyAlloc.ToString("C"))
</Template>
</GridColumn>
<GridCommandColumn>
<GridCommandButton Command="Edit" Icon="edit">Edit</GridCommandButton>
<GridCommandButton Command="Save" Icon="save" ShowInEdit="true">Update</GridCommandButton>
<GridCommandButton Command="Cancel" Icon="cancel" ShowInEdit="true">Cancel</GridCommandButton>
</GridCommandColumn>
</GridColumns>
</TelerikGrid>