Grid in focus

Hi - I have made a page with 4 tabs, and a grid on each tab. 
  <TabItems>
                        <TabItem>
                            <ChildContent>
                                <TabHeader Text="@header1"></TabHeader>
                            </ChildContent>
                            <ContentTemplate>
                                <SfGrid @ref="Grid1" DataSource="@Order" ShowColumnChooser="true" Toolbar="ToolbaritemsString"
                                        AllowResizing="true" AllowPaging="true" AllowFiltering="True"
                                        AllowSorting="true" Height="@gridHeight">
                                         <GridEvents CellSelected="CellSelectHandler" OnActionBegin="OnSave" 
                                             ...

  <TabItems>
                        <TabItem>
                            <ChildContent>
                                <TabHeader Text="@header2"></TabHeader>
                            </ChildContent>
                            <ContentTemplate>
                                <SfGrid @ref="Grid2" DataSource="@Order" ShowColumnChooser="true" Toolbar="ToolbaritemsString"
                                        AllowResizing="true" AllowPaging="true" AllowFiltering="True"
                                        AllowSorting="true" Height="@gridHeight">
                                         <GridEvents CellSelected="CellSelectHandler" OnActionBegin="OnSave" 
                                             ...

In ie. OnActionBegin="OnSave" , how do I know witch grid is in focus? 





3 Replies

VN Vignesh Natarajan Syncfusion Team May 26, 2020 04:17 AM UTC

Hi Soren,  
 
Thanks for contacting Syncfusion support.  
 
Query: “how do I know witch grid is in focus?  
 
From your query we understand that you want to identity which Grid (inside Tab) is currently in focus. We suggest you to achieve your requirement by sending an additional parameter in OnActionBegin containing the Grid ID. Refer the below code example.  
 
<SfTab @ref="Tabs"> 
    <TabItems> 
        <TabItem> 
            <ChildContent> 
                <TabHeader Text="Grid 1"></TabHeader> 
            </ChildContent> 
            <ContentTemplate> 
                <SfGrid @ref="Grid1" DataSource="@Orders" ShowColumnChooser="true" 
                        AllowResizing="true" AllowPaging="true" AllowFiltering="true" 
                        AllowSorting="true"> 
                    <GridEvents OnActionBegin="@((args)=>OnSave(args,"Grid1"))" TValue="Order"></GridEvents> 
. .. .  
                </SfGrid> 
  
            </ContentTemplate> 
        </TabItem> 
        <TabItem> 
            <ChildContent> 
                <TabHeader Text="Grid 2"></TabHeader> 
            </ChildContent> 
            <ContentTemplate> 
                <SfGrid @ref="Grid2" DataSource="@Orders" ShowColumnChooser="true" 
                        AllowResizing="true" AllowPaging="true" AllowFiltering="true" 
                        AllowSorting="true"> 
                    <GridEvents OnActionBegin="@((args)=>OnSave(args,"Grid2"))" TValue="Order"></GridEvents> 
. . . . . 
                </SfGrid> 
  
            </ContentTemplate> 
        </TabItem> 
        <TabItem> 
            <ChildContent> 
                <TabHeader Text="Grid 3"></TabHeader> 
            </ChildContent> 
            <ContentTemplate> 
                <SfGrid @ref="Grid3" DataSource="@Orders" ShowColumnChooser="true" 
                        AllowResizing="true" AllowPaging="true" AllowFiltering="true" 
                        AllowSorting="true"> 
                    <GridEvents OnActionBegin="@((args)=>OnSave(args,"Grid3"))" TValue="Order"></GridEvents> 
. . . . 
                </SfGrid> 
  
            </ContentTemplate> 
        </TabItem> 
        <TabItem> 
            <ChildContent> 
                <TabHeader Text="Grid 4"></TabHeader> 
            </ChildContent> 
            <ContentTemplate> 
                <SfGrid @ref="Grid4" DataSource="@Orders" ShowColumnChooser="true" 
                        AllowResizing="true" AllowPaging="true" AllowFiltering="true" 
                        AllowSorting="true"> 
                    <GridEvents OnActionBegin="@((args)=>OnSave(args,"Grid4"))" TValue="Order"></GridEvents> 
.. . .  
                </SfGrid> 
  
            </ContentTemplate> 
        </TabItem> 
    </TabItems> 
</SfTab> 
 
public void OnSave(ActionEventArgs<Order> Args, string Grid)  {        }
 
For your convenience we have attached the sample which can be downloaded from below  
 
 
Kindly get back to us if you have further queries.   
 
Regards, 
Vignesh Natarajan 



SM Soren M May 26, 2020 06:47 AM UTC

Off course .. an extra parameter. Why didnt I think of that.

Thank you for your quick reply. 


VN Vignesh Natarajan Syncfusion Team May 26, 2020 11:19 AM UTC

Hi Soren,  

Thanks for the update. 

We are glad to hear that you have resolved your query. 

Kindly get back to us if you have further queries.  

Regards, 
Vignesh Natarajan  



Loader.
Up arrow icon