CRUDModel is empty / null when updating

Hi!

I followed one of your samples to enable CRUD mode on the Grid.

The problem is when I edit a record the CRUDModel passed to the Controller is empty.

Inserting works but not editing.


var dataManager = ej.DataManager({
        url: "/Dienstplan/get",
        insertUrl: "/Dienstplan/CellEditInsertDetail",
        updateUrl: "/Dienstplan/CellEditUpdateDetail",
        //removeUrl: "/Dienstplan/CellEditDeleteDetail",
        adaptor: new ej.UrlAdaptor()
    });

$(function () {
        $("#dienstplan").ejGrid({
            dataSource: dataManager,
            locale: 'de-DE',
            allowTextWrap: true,
            textWrapSettings: { wrapMode: ej.Grid.WrapMode.Both },
            editSettings: {
                allowAdding: true,
                allowDeleting: true,
                allowEditing: true,
                rowPosition: "Bottom"
            },
            actionComplete: "onActionComplete",
            isResponsive: true,
            dataBound: 'createColumns',
            columns: [
                { field: "MitarbeiterID", isPrimaryKey: true, visible: false },
                { field: "MitarbeiterName", headerText: "Mitarbeiter", width: 130, allowEditing: true },
                { field: "T1" }
                //{ headerText: "", format: "<a onclick =\"del(this)\" rel='nofollow' href=#>Delete</a>" }
              
            ]
        });
    });

Any idea why this is happening?



3 Replies

VA Venkatesh Ayothi Raman Syncfusion Team December 13, 2017 01:49 PM UTC

Hi Paul, 

Thanks for using Syncfusion products. 

We went through your code example that you have shared for us and found that you are using normal insertUrl,updateUrl and removeUrl instead of crudUrl as well as you are tried to update/insert/delete the data using CRUD model. This is the cause of this issue. 
If we want to perform the CRUD operation using CRUD model at server side then we suggest you to use following code example, 
var dataManager = ej.DataManager({ url: "/Home/DataSource", crudUrl:"/Home/CrudUrl", adaptor: "UrlAdaptor" }); 
 
        $("#Grid").ejGrid({ 
            dataSource: dataManager, 
            . . . 
             editSettings: { allowEditing: true, allowAdding: true, allowDeleting: true }, 
            toolbarSettings: { showToolbar: true, toolbarItems: ["add", "edit", "cancel", "update", "delete"] }, 
            columns: [ 
. .  . 
 
], 
 
 
        }); 
 
[Controller side] 
public ActionResult CrudUrl(EditableOrder value, string action, int key, string keyColumn) 
        { 
            if (action == "update") 
            { 
                OrderRepository.Update(value);                 
                
                 
            } 
            else if (action == "insert") 
            {               
                OrderRepository.Add(value); 
                 
            } 
            else if (action == "remove") { 
                OrderRepository.Delete(key); 
            } 
            return Json(value, JsonRequestBehavior.AllowGet); 
             
        } 

Refer to the following Help documentation for more information, 
We have also prepared a sample for your convenience which can be download from following link, 

Please let us know if you have any further assistance on this. 

Regards, 
Venkatesh Ayothiraman. 



PK Paul Kocher December 15, 2017 11:50 AM UTC

Hello Venkatesh,

thanks for your reply! That makes total sense. I am going to try this today...


VA Venkatesh Ayothi Raman Syncfusion Team December 18, 2017 04:02 AM UTC

Hi Paul, 

Thanks for the update. 

We will wait to hear from you. 

Regards, 
Venkatesh Ayothiraman. 


Loader.
Up arrow icon