CRUD and the ViewModel

Hi!

Can the grid do CRUD just in the page ViewModel?

Thanks!
Bernard.

1 Reply

AG Ajith Govarthan Syncfusion Team May 18, 2020 01:12 PM UTC

Hi Bernard, 

Thanks for contacting Syncfusion support. 

Based on your query we suspect that you need to perform CRUD operation in Grid using ViewModel. So, we have created an sample in Grid using ViewModel and in this sample we also used RemoteSaveAdaptor to perform server-side CRUD operation. 

Find the code example: 


@model filter_core.Models.data; 
@using Syncfusion.EJ2; 
 
 
<div class="container"> 
 
    <ejs-grid id="Grid" allowPaging="true" toolbar="@( new List<object>() {"Add","Edit","Delete","Update","Cancel"})"> 
        <e-data-manager json="@Model.orderData.ToArray()" adaptor="RemoteSaveAdaptor" insertUrl="/Home/Insert" updateUrl="/Home/Update" removeUrl="/Home/CellEditDelete"></e-data-manager> 
        <e-grid-editsettings allowAdding="true" allowDeleting="true" allowEditing="true"></e-grid-editsettings> 
        <e-grid-columns> 
            <e-grid-column field="OrderID" headerText="Order ID" textAlign="Right" isPrimaryKey="true" width="120"></e-grid-column> 
            --------------------------- 
       </e-grid-columns> 
    </ejs-grid> 
</div> 

For your convenience we have attached the sample and please download the sample from the following link 


Regards, 
Ajith G. 


Loader.
Up arrow icon