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

Keeping the .AllowEditing(false) different for the Add form and Edit form

Hello,
I am using the ASP.net MVC grid.
I am using InlineForm to modify the data. I don't want certain fields to be editable so in a column, i have set AllowEditing(False) as shown below. however i do this Fields to be editable in the Add form but its disabled.  does anyone knows how to achieve this?

   col.Field(x => x.Handing)
                                              .HeaderText("Handing")
                                              .TextAlign(TextAlign.Left).AllowEditing(false)
                                              .Width(45)
                                              .Add();

3 Replies

VN Vignesh Natarajan Syncfusion Team November 16, 2018 10:41 AM UTC

Hi Sandip, 
 
Thanks for contacting Syncfusion support.  
 
From your query, we understand that you need prevent the column from being edited and at same time you need to add values to that column while adding. We have achieved your requirement using ActionComplete event of ejGrid.  
 
Refer the below code example 
 
(Html.EJ().Grid<object>("Grid") 
                    .Datasource(ds => ds.URL("UrlDataSource").UpdateURL("UrlUpdate").InsertURL("UrlInsert").RemoveURL("UrlDelete") 
                    .Adaptor(AdaptorType.UrlAdaptor)) 
                    .AllowPaging() 
                    .AllowFiltering() 
                    .AllowGrouping() 
                    .AllowSorting() 
                    .AllowSearching() 
                    .ClientSideEvents(e=>e.ActionComplete("Complete")) 
                    .EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing(); }) 
                    .                    .                 .                .                  .              .          .  
) 
<script type="text/javascript"> 
     
    function Complete(args) {   
        if (args.requestType == "beginedit") {  // disable when request type is beginedit  
            //Grid ID + ColumnName 
            $("#GridCustomerID").addClass("e-disable");    
            $("#GridCustomerID").attr("disabled",true);  // disable the element from editing 
        } 
    } 
    </script> 
 
For your convenience we have prepared a sample which can be downloaded from below link 
 
 
Refer the below Knowledge base document to disable the dropdownlist while editing and enable it while adding  
 
 
Refer our help documentation for your reference 
 
 
 
Please get back t us if you have further queries. 
 
 
Regards 
Vignesh Natarajan  



SA Sandip November 19, 2018 12:21 AM UTC

Thanks. This solution works for me.


VN Vignesh Natarajan Syncfusion Team November 19, 2018 08:25 AM UTC

Hi Sandip, 


Thanks for the update. 


We are glad to hear that your query has been resolved by your solution. 


Please get back to us if you have further queries. 


Regards, 
Vignesh Natarajan  


Loader.
Live Chat Icon For mobile
Up arrow icon