How to set different default setting to texbox in grid when adding and editing

Hello,

I'm working on grid with add and edit button.
EditType for one of the column in grid is "string" which is textbox.

My requirement is when adding the new row, this column needs to be  AllowEditing="true"
when edit the row, this column should be AllowEditing="false"

Is it possible to do that?

Best Regards,
Yukiko

3 Replies

SS Seeni Sakthi Kumar Seeni Raj Syncfusion Team August 10, 2018 11:04 AM UTC

Hi Yukiko,  
 
Thanks for contacting Syncfusion Support.  
 
To disable the Editing for column, set the AllowEditing as “false”. At the same time, this property disables the respective field while the adding the records also. In order to handle this case, we suggest to toggling this functionality in the ActionBegin event of the Grid as shown in the following code example. 
 

    <ej:Grid ID="Grid1" AllowPaging="True" runat="server"> 
                    <Columns> 
                        <ej:Column Field="EmployeeID" HeaderText="Employee ID" AllowEditing="false" TextAlign="Right" Width="110" /> 
                                    . .  
                                     . . .  
                    </Columns> 
                    <ClientSideEvents ActionBegin="onbegin"/> 
                            . . . 
                    <EditSettings AllowEditing="True" AllowAdding="True" AllowDeleting="True"></EditSettings> 
                </ej:Grid> 
<script> 
    function onbegin(args) { 
         if(args.requestType == "add"){ 
             this.model.columns[2].allowEditing = true; // Enable the editing for EmployeeID column while adding the record. 
        } 
        if (args.requestType == "save") { 
             this.model.columns[2].allowEditing = false; // Disable the editing for EmployeeID column while editing the record. 
 
        } 
    } 
</script> 

 
Refer to the API References.  
 
 
Also refer the below link for sample, 
 
Regards,  
Seeni Sakthi Kumar S. 



YI Yukiko Imazu August 10, 2018 03:24 PM UTC

Hi Seeni Sakthi Kumar,

Thank you for your sample.
I could resolve my issue.

Best Regards,
Yukiko


PK Prasanna Kumar Viswanathan Syncfusion Team August 13, 2018 08:33 AM UTC

Hi Yukiko, 
 
We are happy to hear that your issue has been solved. 
 
Please get back to us if you need any further assistance. 
 
Regards, 
Prasanna Kumar N.S.V 


Loader.
Up arrow icon