We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

How can I get the ID of the Grid component?

I can't seem to find a way to get the ID of the Grid Component.
Given the following grid
<EjsGrid DataSource="@Orders" @ref="@DefaultGrid" @ref:suppressField ID="test" Toolbar="@(new List<string>() { "Search" })" AllowPaging="true" AllowSorting="true" AllowResizing="true" AllowFiltering="true"
             AllowGrouping="true" AllowExcelExport="true" AllowPdfExport="true" ContextMenuItems="@MenuItems">
        <GridEvents TValue="SyncfusionBlazorTest.Data.Order" ContextMenuItemClicked="ItemClicked" Created="GridCreated" OnActionComplete="GridLoaded" DataBound="GridDataBound"></GridEvents><!--ContextMenuItemClicked="ItemClicked" OnPdfExport="PdfExport"-->
        <GridPageSettings PageSize=5></GridPageSettings>
    </EjsGrid>

I have tried getting the Id on
"Created"
"OnActionComplete" and
"DataBound" to no avail.


Thanks in advance

Doug Kuchna

3 Replies

VN Vignesh Natarajan Syncfusion Team August 21, 2019 10:06 AM UTC

Hi Doug,  

Greetings from Syncfusion support.  

Query: “I can't seem to find a way to get the ID of the Grid Component. 

We are glad to announce that our latest Nuget release (17.2.46) has been successfully release and kindly find the latest Nuget package from below  


So kindly refer our latest Nuget package from nuget.org instead of private build. We suspect that you need to get the Grid instance using the ID to perform certain actions in Grid. We suggest you to take the Grid instance using @ref property of Grid. Refer the below code example. 

<EjsGrid DataSource="@Orders" @ref="@DefaultGrid" @ref:suppressField ID="test" AllowPaging="true"> 
………………………………………. 
    </EjsGrid> 
 
@code{ 
    EjsGrid<Order> DefaultGrid { get; set; } 
    public List<Order> Orders { get; set; } 
    ……………………………….. 
    public void GridLoaded(ActionEventArgs<Order> Args) 
    { 
        DefaultGrid.AddRecord();    //DefaultGrid is the instance of the grid. You can call the public method from it. 
    } 
    public void GridDataBound() 
    { 
 
    } 
    ……………………………….. 
} 

If above solution does not resolve your query, please get back to us with more details of your requirement.   

Regards,
Vignesh Natarajan. 



DK doug kuchna August 21, 2019 10:34 AM UTC

Thank you much, this resolves my issue


VN Vignesh Natarajan Syncfusion Team August 22, 2019 09:05 AM UTC

Hi Doug, 

Thanks for the update.  

We are happy to hear that your query has been resolved by our solution.  

Please get back to us if you have any further queries. 

Regards, 
Vignesh Natarajan. 


Loader.
Live Chat Icon For mobile
Up arrow icon