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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Getting selected rows in grid

Thread ID:

Created:

Updated:

Platform:

Replies:

145831 Jul 9,2019 11:20 PM UTC Jul 11,2019 12:21 PM UTC Blazor 2
loading
Tags: Grid
Ivan Petrov
Asked On July 9, 2019 11:20 PM UTC

Hello

When trying to get the selected rows the list is empty. My code is: 

@page "/"
@using Data
@using Syncfusion.EJ2.Blazor.Grids
@using Syncfusion.EJ2.Blazor.Popups
@using Newtonsoft.Json;

<button @onclick=@(() => this.GetRows())>get</button>

@this.Temp

<EjsGrid @ref=this.defaultGrid DataSource=@this.gridData AllowSelection="true">
    <GridSelectionSettings PersistSelection="true"></GridSelectionSettings>
    <GridColumns>
        <GridColumn Type="checkbox" Width="50"></GridColumn>
        <GridColumn Field=@nameof(OrdersDetails.CustomerID) HeaderText="Customer Name"></GridColumn>
        <GridColumn Field=@nameof(OrdersDetails.OrderDate) HeaderText="Order Date" Format="yMd"></GridColumn>
        <GridColumn Field=@nameof(OrdersDetails.Freight) HeaderText="Freight" Format="C2"></GridColumn>
        <GridColumn Field=@nameof(OrdersDetails.ShipCountry) HeaderText="Ship Country"></GridColumn>
    </GridColumns>
</EjsGrid>

@functions{
    EjsGrid defaultGrid;

    public List<OrdersDetails> gridData { get; set; }

    public object Temp { get; set; }

    public void GetRows()
    {
        var temp = this.defaultGrid.GetSelectedRows();

        temp.GetAwaiter().OnCompleted(() =>
                {
                    this.Temp = temp.Result;
                    this.Invoke(this.StateHasChanged);
                });
    }

    protected override async Task OnInitAsync()
    {
        await base.OnInitAsync();

        this.gridData = OrdersDetails.GetAllRecords();
    }
}


Vignesh Natarajan [Syncfusion]
Replied On July 10, 2019 04:04 PM UTC

Hi Ivan, 

Thanks for contacting Syncfusion forum.  

Query: “When trying to get the selected rows the list is empty 

We have analyzed the provided code example and we are able to reproduce the reported behavior at our end while preparing a sample using your code example. Currently we are validating your scenario and we will update you the further details by 11th July 2019.  

Till then we appreciate your patience.   

Regards, 
Vignesh Natarajan. 


Vignesh Natarajan [Syncfusion]
Replied On July 11, 2019 12:21 PM UTC

Hi Ivan,  

Thanks for the patience. 

Query: “When trying to get the selected rows the list is empty 

We have validated the reported issue at our end by preparing a sample using your code example and we are able to reproduce the reported issue. We have considered the reported query as a bug and it will be included in our next patch release which is expected to be roll out on or before 23rd July 2019.  

You can track the status of the issue using the below feedback 


Till then we appreciate your patience.  

As a workaround you can get the DOM elements using RowSelectedEvents. It will be triggered for each row selection.  

Refer the below code example 

<EjsGrid @ref=defaultGrid DataSource=@gridData RowSelected="rowselect" AllowSelection="true"> 
………………………………………. 
</EjsGrid> 
 
public List<DOM> Temp { get; set; } 
public List<Orders> order = new List<Orders>(); 
public void rowselect(RowSelectEventArgs args) 
{ 
    this.Temp.Add(args.Row); 
} 

Note: GetSelectedRows() method will return the row elements (i.e) DOM elements in form of array collection. If you want to get the selected record details, we suggest you to achieve your requirement using GetSelectedRecords().  
 
Refer the below screenshot for your reference 

public void GetRows() 
{ 
    var temp = this.defaultGrid.GetSelectedRecords(); // return the details of selceted record 
 
    temp.GetAwaiter().OnCompleted(() => 
    { 
        this.Temp = temp.Result; // here you can get the selected row datas in form list of objects. 
        this.Invoke(this.StateHasChanged); 
    }); 
} 

Please get back to us if you have further queries.  
    
Regards, 
Vignesh Natarajan. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon