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
close icon

Field edit template

Hi, I have a boolean field in my grid. When user add a new row, I would like to prevent edit on this field (other fields are still editable). After the record is added to the grid, user can edit this field. How to achieve that?

Thanks.

8 Replies

NG Nga June 7, 2017 09:08 AM UTC

The edit mode is normal.


JK Jayaprakash Kamaraj Syncfusion Team June 8, 2017 09:19 AM UTC

Hi Customer, 

Thank you for contacting Syncfusion support. 

We have achieved your requirement using actionComplete event and allowEditing columns property of ejGrid. We need to set allowEditing property as false for boolean column and then we need to remove disabled attribute and e-disable class in boolean column when args.requestType as beginedit in actionComplete event of ejGrid. Please refer to the below help document, code example and sample. 


<script type="text/javascript"> 
    $(function () { 
        $("#Grid").ejGrid({ 
            // the datasource "window.gridData" is referred from jsondata.min.js 
            dataSource: window.gridData, 
            allowPaging: true, 
            actionComplete: function (args) { 
                if (args.requestType == "beginedit") 
                    $("#" + this._id + "Verified").removeAttr("disabled").removeClass("e-disable"); 
            }, 
            editSettings: { allowEditing: true, allowAdding: true, allowDeleting: true }, 
            toolbarSettings: { showToolbar: true, toolbarItems: [ej.Grid.ToolBarItems.Add, ej.Grid.ToolBarItems.Edit, ej.Grid.ToolBarItems.Delete, ej.Grid.ToolBarItems.Update, ej.Grid.ToolBarItems.Cancel] }, 
            columns: [ 
                    { field: "OrderID", isPrimaryKey: true, headerText: "Order ID", textAlign: ej.TextAlign.Right, validationRules: { required: true, number: true }, width: 90 }, 
             .. 
 
                  { field: "Verified", headerText: 'Verified', editType: ej.Grid.EditingType.Boolean, allowEditing: false, width: 90 } 
            ] 
        }); 
 
 
    }); 
 
 
</script> 


Regards, 

Jayaprakash K. 
 



NG Nga June 8, 2017 02:56 PM UTC

Thank you. Your sample works as expected.
Continue to this case, I would like to have one column displaying a button that will call custom command. I checked http://js.syncfusion.com/demos/web/#!/bootstrap/grid/columns/customcommand but the problem is: I would like the button to be displayed on some rows based on condition. How to achieve that?

Thanks.


JK Jayaprakash Kamaraj Syncfusion Team June 9, 2017 06:56 AM UTC

Hi Customer, 

We have achieved your requirement using rowDataBound event of ejGrid. In this event, we can display command button based on your condition. Please refer to the below help document, code example and sample. 


<script type="text/javascript"> 
    $(function () { 
        $("#Grid").ejGrid({ 
            // the datasource "window.employeeData" is referred from templatelocaldata.js 
            dataSource: window.employeeData, 
            enableRowHover: false, 
            allowSelection: false, 
            rowDataBound: function (args) { 
                if (args.rowData.Country == "UK") 
                    $(args.row).find(".e-detailsbutton").hide(); 
            }, 
            columns: [ 
.. 
                     { 
                         headerText: "Employee Details", 
                         commands: [ 
                             { 
                                 type: "details", 
                                 buttonOptions: { 
                                     text: "Details", 
                                     width: "100", 
                                     click: "onClick" 
                                 } 
                             } 
                         ], 
                         isUnbound: true, 
                         textAlign: ej.TextAlign.Left, 
                         width: 150 
                     } 
            ] 
        }); 
.. 
    }); 
</script> 


Regards, 

Jayaprakash K. 
 



NG Nga June 11, 2017 03:56 PM UTC

Hi, How to hide that custom Details button when user is adding or editing row?


FS Farveen Sulthana Thameeztheen Basha Syncfusion Team June 12, 2017 12:58 PM UTC

Hi Customer, 

You can hide the custom details button while add/edit the row by using “cssClass”  property  of the Grid. We can achieve it by giving the “display:none”  for .e-unboundcelldiv class while add/edit row. 

Please refer to the code example:- 
 
  <style> 
    .e-grid.hideEditUnbound .gridform .e-unboundcelldiv{ 
       display: none; 
    } 
  </style> 
    <script type="text/javascript"> 
        $(function () { 
            $("#Grid").ejGrid({ 
                // the datasource "window.employeeData" is referred from templatelocaldata.js 
                dataSource: window.employeeData, 
                enableRowHover: false, 
                allowSelection: false, 
                toolbarSettings: { showToolbar: true, toolbarItems: [ej.Grid.ToolBarItems.Add, ej.Grid.ToolBarItems.Edit, ej.Grid.ToolBarItems.Delete, ej.Grid.ToolBarItems.Update, ej.Grid.ToolBarItems.Cancel] }, 
                editSettings: { allowEditing: true, allowAdding: true, allowDeleting: true }, 
               cssClass: "hideEditUnbound", 
                rowDataBound: function (args) { 
                    if (args.rowData.Country == "UK") 
                        $(args.row).find(".e-detailsbutton").hide(); 
                }, 
                columns: [ 
                      .  .  . 
                         { 
                             headerText: "Employee Details", 
                             commands: [ 
                                 { 
                                     type: "details", 
                                     buttonOptions: { 
                                         text: "Details", 
                                         width: "100", 
                                         click: "onClick" 
                                     } 
                                 } 
                             ], 
                             isUnbound: true, 
                             textAlign: ej.TextAlign.Left, 
                             width: 150 
                         } 
                ] 
            }); 
        }); 
   </script> 



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

Regards, 

Farveen sulthana T 



NG Nga June 12, 2017 03:26 PM UTC

Thank you for your support.


JK Jayaprakash Kamaraj Syncfusion Team June 13, 2017 08:44 AM UTC

Hi Customer,  
 
Thanks for the update. 
 
Please get back to us if you need any further assistance.   
 
Regards,  
 
Jayaprakash K. 


Loader.
Live Chat Icon For mobile
Up arrow icon