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

grid with RemoteServer function is not passed into the parameter value

I create web applications with asp mvc vNext and syncfusion last edition, when I use the grid with RemoteServer function, the data that the change is not passed into the parameter value, if there is something wrong in the code below:

Controller:

public async Task<IActionResult> GetDataChemicals(DataManager dm)
{
    IEnumerable data = await _chemical.GetAllAsync(); 
    DataOperations operation = new DataOperations();
    if (dm.Sorted != null && dm.Sorted.Count > 0) //Sorting
    {
       data = operation.PerformSorting(data, dm.Sorted);
    }
    if (dm.Where != null && dm.Where.Count > 0) //Filtering
    {
      data = operation.PerformWhereFilter(data, dm.Where, dm.Where[0].Operator);
    }
    int count = data.Cast<Chemical>().Count();
    if (dm.Skip != 0)
    {
       data = operation.PerformSkip(data, dm.Skip);
    }
    if (dm.Take != 0)
    {
       data = operation.PerformTake(data, dm.Take);
    }
    return Json(new { result = data, count = count });
}

    public IActionResult Insert(Chemical value)
    {
           //this code
    }

    public ActionResult Update(Chemical value)
    {

           //this code
    }

    public IActionResult Remove(int key)
    {
           this code
    }

View:;
@{
    Html.EJ().Grid<Chemical>("ChemicalGrid")
        .Datasource(ds => ds.Json((IEnumerable<object>)ViewBag.datasource).UpdateURL("/Chemicals/Update")
        .InsertURL("/Chemicals/Insert").RemoveURL("/Chemicals/Remove").Adaptor(AdaptorType.RemoteSaveAdaptor))
        .AllowSorting()
        .EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing(); })
        .ToolbarSettings(toolbar =>
        {
            toolbar.ShowToolbar().ToolbarItems(items =>
            {
                items.AddTool(ToolBarItems.Add);
                items.AddTool(ToolBarItems.Edit);
                items.AddTool(ToolBarItems.Delete);
                items.AddTool(ToolBarItems.Update);
                items.AddTool(ToolBarItems.Cancel);
            });
        })
        .AllowPaging()
        .AllowMultiSorting()
        .SortSettings(sort =>
        {
            sort.SortedColumns(col => col.Field("ChemicalId").
        .Columns(col =>
        {
            col.Field("ChemicalId").HeaderText("Id").IsPrimaryKey(true).TextAlign(TextAlign.Right).Add();
            col.Field("ChemicalStation").HeaderText("Station").EditType(EditingType.String).ValidationRules(v => v.AddRule("required"true).AddRule("minlength", 2)).TextAlign(TextAlign.Right).Add();
            col.Field("ChemicalDistance").HeaderText("Distance").EditType(EditingType.Numeric).NumericEditOptions(new EditorProperties() { DecimalPlaces = 2, }).TextAlign(TextAlign.Right).Add();
            col.Field("ChemicalBod").HeaderText("Bod").EditType(EditingType.Numeric).NumericEditOptions(new EditorProperties() { DecimalPlaces = 2, }).TextAlign(TextAlign.Right).Add();
            col.Field("ChemicalDo").HeaderText("Do").EditType(EditingType.Numeric).NumericEditOptions(new EditorProperties() { DecimalPlaces = 2, }).TextAlign(TextAlign.Right).Add();
            col.Field("ChemicalQ").HeaderText("Q").EditType(EditingType.Numeric).NumericEditOptions(new EditorProperties() { DecimalPlaces = 2, }).TextAlign(TextAlign.Right).Add();
        })
        .Render();
}

On performing CRUD operations in Grid, the record changes will be sent to server-side as in the following screenshot.
Header result 
Preview

4 Replies

AH ahmad August 9, 2016 12:17 PM UTC

use action name only without controller name 


JK Jayaprakash Kamaraj Syncfusion Team August 9, 2016 12:45 PM UTC

Hi Anggoro,   
  
Thank you for contacting Syncfusion support.   
  
For ASP.NET MVC vNext sample, we can get the dynamic value using “[FromBody]CrudModel” as follows,    
 
{Html.EJ().Grid<Object>("FlatGrid") 
        .Datasource(ds => ds.Json((IEnumerable<object>)ViewBag.data).UpdateURL("/Home/CellEditUpdate").InsertURL("/Home/CellEditInsert").RemoveURL("/Home/CellEditDelete").Adaptor(AdaptorType.RemoteSaveAdaptor)) 
                .EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing(); }) 
                .AllowPaging() 
                                .. 
                                }).Render(); 
    } 

HomeController.cs 
namespace WebApplication8.Controllers 
{ 
    public class HomeController : Controller 
    { 
        .. 
 
        public ActionResult CellEditUpdate([FromBody]CRUDModel<Orders> value) 
        { 
          // do your operations here 
        } 
        public ActionResult CellEditInsert([FromBody]CRUDModel<Orders> value) 
        { 
             // do your operations here  
        } 
        public ActionResult CellEditDelete([FromBody]CRUDModel<Orders> value) 
        { 
              // do your operations here 
        } 
    } 
} 



Regards, 

Jayaprakash K. 



AN anggoro August 11, 2016 10:53 AM UTC

Oke thanks.. i try this.


JK Jayaprakash Kamaraj Syncfusion Team August 12, 2016 04:04 AM UTC

Hi Anggoro, 
 
Thanks for the update. 
 
Please get back to us for further assistance. 
 
Regards, 
 
Jayaprakash K. 


Loader.
Live Chat Icon For mobile
Up arrow icon