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

Grid with ObservableCollection?

Thread ID:

Created:

Updated:

Platform:

Replies:

147537 Sep 14,2019 10:38 PM UTC Sep 17,2019 10:07 AM UTC Blazor 3
loading
Tags: Grid
Manuel Reinacher
Asked On September 14, 2019 10:43 PM UTC

Hello ;)

I want to use the Grid in a server side application  to edit a few values which needs processing after editing.
So I need an event when the user changed something in the List.
My idea was to use an ObservableCollection to implement this.

For adding a new value this works fine, but it looks like editing and removing is not working.
I'm getting an error in the browser console when I turn detailed error reporing on.

I assume, that I can use any IEnumerable as a DataSource?

(I can not paste the code here after an edit - some parts are missing...)



regards Manuel





Vignesh Natarajan [Syncfusion]
Replied On September 16, 2019 06:26 AM UTC

Hi Manuel,  

Thanks for contacting Syncfusion support.  

Query: “For adding a new value this works fine, but it looks like editing and removing is not working. 
                                                      
We have prepared a sample using your code example and we are able to reproduce the reported issue at our end too. The root cause of an issue is while performing CRUD (Add, Edit, Delete etc ) action, it is necessary to define the IsPrimaryKey property to any of the available Grid columns. (i.e) one column must be PrimaryKey column whose value must be unique. Based on primaryKey value only, inserting, editing, deleting operation will take place. Refer our UG documentation for your reference 


Refer the below cod example for your reference 

<EjsGrid DataSource="@ObsOrders"  AllowPaging="true" Toolbar="@(new List<string>() { "Add", "Edit", "Delete" })"> 
    <GridColumns> 
        <GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" IsPrimaryKey="true" TextAlign="TextAlign.Right" Width="120"></GridColumn> 
…………………… 
</EjsGrid> 
 

Please get back to us if you have further queries.  

Regards,
Vignesh Natarajan. 


Manuel Reinacher
Replied On September 16, 2019 11:30 AM UTC

Hello Vignesh Natarajan,

Thanks for your help.

Adding and removing is now working fine.
When I edit a value I don't get any CollectionChanged event on the list.

- This would be very useful, because then you could use these events to handle the changes from the grid.

regards Manuel



Vignesh Natarajan [Syncfusion]
Replied On September 17, 2019 10:07 AM UTC

Hi Manuel, 

Thanks for the update.   

We are glad to hear that your query has been resolved.  

Query: “When I edit a value I don't get any CollectionChanged event on the list. 
 
CollectionChanged method itself will be triggered only when entire list is changed, removed or added. So it will not be triggered when one of the individual member is changed. Refer the below stackoverflow link for your reference. 


Same requirement (use these events to handle the changes from the grid) can be achieved using OnActionComplete event of EjsGrid. This event will be triggered whenever certain actions are completed in Grid. In the event arguments you can get the modified data and request type.  

Refer the below code example  

<EjsGrid DataSource="@ObsOrders"  AllowPaging="true"  Toolbar="@(new List<string>() { "Add", "Edit", "Delete" })"> 
    <GridEvents OnActionComplete="OnComplete" TValue="Order"></GridEvents> 
    .          .            .         .        .     .  
</EjsGrid> 
.          .            .        .         .  
  public void OnComplete(ActionEventArgs<Order> Args) 
    { 
        if(Args.RequestType.ToString() == "Save") 
        { 
 
        } 
    } 
  
Also refer our UG documentation for the list of available events 


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