Grid Edit

Hello,

In my example, I have not set up the columns. They are automatically created at runtime.

How can I stop the edit from being able to change the OrderID column.




I tried in the code behind 

 Grid1.Columns[0].AllowEditing = false;

But this doesn't work?



Attachment: Test2.aspx_1dc03f5f.zip

1 Reply

KM Kuralarasan Muthusamy Syncfusion Team July 5, 2018 10:54 AM UTC

Hi David, 

Thanks for contacting Syncfusion support. 

We have analyzed your query and we found that you want to disable the OrderID field while  editing the grid. Also you have mentioned the columns are automatically created in your project. So we suggest you to set the IsPrimaryKery property (If OrderID field has unique value) as true or set allowingEditing as false (If OrderID field does not have unique value) by using client side dataBound event of the Grid. Please refer the following code snippet: 

If you want to use IsPrimaryKey: 
 
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> 
    <ej:Grid ID="Grid1" runat="server"> 
        <ClientSideEvents DataBound="bound" /> 
    </ej:Grid> 
 
    <script type="text/javascript"> 
        function bound(args) { 
            var col = args.model.columns[0]; 
            col.isPrimaryKey = true; 
            this.columns(col, "update"); 
        } 
    </script> 
</asp:Content> 
 
If you want to set allowEditing as false: 
 
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> 
 
    <script type="text/javascript"> 
        function bound(args) { 
            var col = args.model.columns[0]; 
            col.allowEditing = false; 
            this.columns(col, "update"); 
        } 
    </script> 
 
</asp:Content> 
 

We have prepared the sample with your requirement and that sample can be downloadable from the below link, 


We have already discussed about this topic in our help documentation and refer the following link to help documentation: 


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

Regards, 
Kuralarasan M.  


Loader.
Up arrow icon