Disable column during adding record.

I use Grid and I have the following column.

columns: [
                    { field: "Id", isPrimaryKey: true, headerText: "ID", allowEditing: false, defaultValue: 0, visible: true },
                    { field: "Name", headerText: "Company Name", allowEditing: true },
            ]

Is there any way to disable field named Id during adding new record?

1 Reply

FS Farveen Sulthana Thameeztheen Basha Syncfusion Team November 1, 2017 04:55 PM UTC

Hi Maciej, 

Thanks for contacting Syncfusion Support. 

We have checked your query and if you want to disable the ID column  with isPrimaryKey property while adding the new record, you can achieved it by “isIdentity” property of the Grid. While using isIdentity on performing crud operations, it is necessary to handle the isIdentity property while updating records in the database. In the below code example, we have bind the autoincreament value to “isIdentity” column and insert into the database. 

Please refer to the code example:- 

script type="text/javascript"> 
    $(function () { 
        // the datasource "window.gridData" is referred from jsondata.min.js 
        $("#Grid").ejGrid({ 
            dataSource: ej.DataManager({ 
                url: "Home/DataSource", 
                updateUrl: "Home/Update", 
                insertUrl: "Home/Insert", 
                removeUrl: "Home/Delete", 
                adaptor: "UrlAdaptor" 
            }), 
            allowPaging: true, 
             columns: [ 
                    { field: "OrderID",isIdentity:true, isPrimaryKey:true, headerText: "Order ID", width: 80 }, 
                    { field: "ShipCity", headerText: "Ship City", width: 90, priority: 2 }, 
                    { field: "ShipCountry", headerText: "Ship Country", width: 90 } 
            ], 
        }); 
    }); 
 
Serverside:- 
        public static void Insert(Order value) 
        { 
            value.OrderID = ++count; //Auto increment the value for isIdentity property   
            ord.Add(value); 
            return Json(value, JsonRequestBehavior.AllowGet); 
        } 

Please refer to the documentation Link:- 



Please get back to us if you need any further assistance. 

Regards, 

Farveen sulthana T 




Loader.
Up arrow icon