Open ItsTahaRehman opened 1 year ago
You can have a SelectedRowChanged
callback.
<DataGrid SelectedRowChanged="@OnSelectedRowChanged">
Task OnSelectedRowChanged(Person item)
{
return Task.CompleteTask;
}
hello @stsrki
basically what i want to do is that i have created a component for the datagrid so i can reuse the data grid in multiple places with the same configurations and settings. Following is the code of that datagrid component
`<DataGrid Class="@Class" TItem="T" @ref="DataGrid" @bind-SelectedRow="SelectedRowItem" Virtualize Data="@ItemList" Editable Responsive ShowPager CommandMode="DataGridCommandMode.Default" EditMode="DataGridEditMode.Popup" TotalItems="@TotalCount" PageSize="@PageSize" VirtualizeOptions="@(new Blazorise.DataGrid.VirtualizeOptions{ DataGridHeight="auto",DataGridMaxHeight="80vh" })" UseValidation Filterable="true" ShowValidationFeedback="false" ShowValidationsSummary="false" RowSelectable="(rowSelectableEventArgs) => { return rowSelectableEventArgs.SelectReason is not DataGridSelectReason.RowClick;}" ReadData="@OnReadData" FixedHeader="true" HeaderThemeContrast="ThemeContrast.Dark" DetailRowTrigger="(e)=>{DetailRowTriggered.Invoke(e.Item); return true;}" RowRemoved="async (e)=> {await RowRemovedFunction.InvokeAsync(e);}" RowUpdated="async (e)=> {await RowUpdatedFunction.InvokeAsync(e.Item);}" RowInserted="async (e)=>{await RowInsertedFunction.InvokeAsync(e.Item);}" PopupSize="@PopupSize">
<ButtonRowTemplate>
@if(ShowAddNewButtton)
{
<div class="new-item-btn-div">
<Blazorise.Button Color="Color.Danger" Clicked="async ()=>{await NewCommandFunction.InvokeAsync(); await context.NewCommand.Clicked.InvokeAsync();}">@Localizer.Get("AddNewRecord")<Icon Class="fa fa-plus" Padding="Padding.Is3.FromStart" TextColor="TextColor.White" /></Blazorise.Button>
</div>
}
</ButtonRowTemplate>
<EmptyTemplate>
<div class="text-center">
@Localizer.Get("NoRecordsFound")
</div>
</EmptyTemplate>
<LoadingTemplate>
<div class="spinner-div text-center">
<SpinKit Type="SpinKitType.Chase" Centered Color="#071b45" />
</div>
</LoadingTemplate>
<PopupTitleTemplate>
</PopupTitleTemplate>
<DetailRowTemplate>
@DetailRowTemplate
</DetailRowTemplate>
`
as u can see that in the detailrowtemplate component im using the RenderFragment named DetailRowTemplate
What i want to achieve
So kindly let me know if there is any solution regarding this or is there any other workaround for this situation
Thanks @ItsTahaRehman
@ItsTahaRehman
Are you looking for the context inside the DataGridRowInfo<TItem>
? Basically whether the DetailRow is shown or not? Is that it?
Maybe we could expose
What do you think @stsrki ?
@David-Moreira @stsrki what i need is that i want to use the context of the detail row template in the render fragment , in the last comment you added can we get the context of the current row as we do in the detailrowtemplate
Yes, this is what's inside of it https://github.com/Megabit/Blazorise/blob/master/Source/Extensions/Blazorise.DataGrid/Models/DataGridRowInfo.cs
in the datagrid component we have the row context which we can access in some of the child components such as the display template or the detail row template
Can we have some sort of callback or method through which we can access the row context of a particular row on the basis of some unique key