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 : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Save changes in Datatable

Thread ID:

Created:

Updated:

Platform:

Replies:

132350 Aug 28,2017 09:10 AM UTC Aug 29,2017 02:42 PM UTC ASP.NET MVC 1
loading
Tags: Grid
ALJANE
Asked On August 28, 2017 09:10 AM UTC

Hi Syncfusion!!

I working with Grid (DataTable as Datasource) and i need to perform Editing and then save it into the same Datatable,


My Grid :

@model System.Data.DataTable

@(Html.EJ().Grid<Object>("FlatGrid")

                    .Datasource((System.Data.DataTable)Model)

                    .AllowPaging()

                    .AllowSelection()

                    .AllowResizeToFit(true)

                    .AllowScrolling()

                    .EditSettings(edit => { edit.AllowEditing().EditMode(EditMode.Normal); })

                    .ToolbarSettings(toolbar =>

                    {

                        toolbar.ShowToolbar().ToolbarItems(items =>

                        {

                            items.AddTool(ToolBarItems.Edit);

                            items.AddTool(ToolBarItems.Update);

                            items.AddTool(ToolBarItems.Cancel);

                        });

                    })

                    .Columns(col =>

                    {


                        col.Field("ID").AllowEditing(false).Width(50).IsFrozen(true).IsPrimaryKey(true).Add();

                        col.Field("VAR1").AllowEditing(false).Width(200).Add();

                        col.Field("VAR2").AllowEditing(false).Width(100).IsFrozen(true).Add();

                        col.Field("VAR3").AllowEditing(false).Width(50).Add();

                        col.Field("VAR4").AllowEditing(false).Add();

                        col.Field("VAR5").AllowEditing(false).Add();

                        col.Field("VAR6").AllowEditing(true).EditType(EditingType.String).Add();


                    })


)


How can i change this to work??

Thanks

O.A


Thavasianand Sankaranarayanan [Syncfusion]
Replied On August 29, 2017 02:42 PM UTC

Hi Aljane, 

Thanks for contacting Syncfusion support. 

We have analyzed your query and we suggest you to perform the CRUD operations in server side by specifying the adaptor type as RemoteSaveAdaptor adaptor and also specify the CRUD actions Url to the corresponding DataManager properties of grid. The corresponding server side CRUD actions methods has been triggered when we perform any CRUD action in grid.  

Refer the below screen shot. 

  1. Initial Rendering.

 

  1. While Editing.
 
 

  1. Edited value get in server side.

 


Refer the below code example. 

[Index.cshtml] 

@(Html.EJ().Grid<object>("Editing") 
        .Datasource(ds => ds.Json((System.Data.DataTable)ViewBag.dataSource) 
            .UpdateURL("ExternalUpdate").InsertURL("ExternalInsert").RemoveURL("ExternalDelete") 
            .Adaptor(AdaptorType.RemoteSaveAdaptor)) 
         
         
         .AllowPaging() 
         
         ---- 
 
       .Columns(col => 
        { 
            col.Field("OrderID").HeaderText("Order ID").IsIdentity(true).IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(90).ValidationRules(v => v.AddRule("required", true).AddRule("number", true)).Add(); 
             
            ----- 
 
       }) 
        
) 
 
 
------------------------------------- 
[HomeController.cs] 

 
        public ActionResult ExternalUpdate(EditableOrder value) 
        { 
           //do your stuff here for update a record in database 
        } 
 
        public ActionResult ExternalInsert(EditableOrder value) 
        { 
             
           //do your stuff here for remove a record in database 
 
       } 
 
        public void ExternalDelete(int key) 
        {   
 
            //do your stuff here for remove a record in database 
 
        } 
     } 


Refer the help documentation. 


Regards, 
Thavasianand S. 


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.

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

;