how to set and get row template record id


hello, this is button in row template and on click I would like to get record or record id
if possible I want hide in each of  grids row template record, hidden id and read it on button click

1 Reply 1 reply marked as answer

VN Vignesh Natarajan Syncfusion Team February 8, 2021 06:50 AM UTC

Hi Aleqsandre,  
 
Thanks for contacting Syncfusion support.  
 
Query: “if possible I want hide in each of  grids row template record, hidden id and read it on button click 
 
We have analyzed your query and we understand that you want to display some text in row template of Grid on button click. We have achieved your requirement by rendering the component inside the RowTemplate as separate component and displayed the text using Boolean value.  
 
Refer the below code example.  
  
<SfGrid DataSource="@Employees" Height="335px"> 
    <GridTemplates> 
        <RowTemplate Context="emp"> 
            @{ 
                var employee = (emp as EmployeeData);                 
. .  
                                <BtnComp Record="employee"></BtnComp> 
. . . . 
            } 
        </RowTemplate> 
    </GridTemplates> 
    <GridColumns>         
        <GridColumn HeaderText="Employee Details" Width="300" TextAlign="TextAlign.Left"></GridColumn> 
    </GridColumns> 
</SfGrid> 
 
[btnComp.razor] 
 
@using Syncfusion.Blazor.Buttons@using Grid.Data  <td class="CardHeader">First Name </td><SfButton OnClick="@(()=>Clicked(Record))" Content="Get Data"></SfButton>@if (ToggleData){ <td>@Record.FirstName</td>} @code{    [Parameter]    public EmployeeData Record { getset; }    public bool ToggleData { getset; }    public void Clicked(EmployeeData value)    {        if (ToggleData) ToggleData = false;        else ToggleData = true;    }}
 
Kindly download the sample from below which we have prepared using above solution.  
 
 
Please get back to us if you have further queries. 
 
Regards, 
Vignesh Natarajan 


Marked as answer
Loader.
Up arrow icon