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

Conditional AllowEditing ejGrid

Hello,

there is any way to set allowEditing true or false depending on the value of an ejGrid field?

In the same grid I have records that can be edited but there are others that should not be able to edit. 


Thank you in advance.
Bruno Rodrigues

5 Replies

IR Isuriya Rajan Syncfusion Team August 4, 2015 03:38 PM UTC

Hi Bruno,

You can achieve your requirement by using “allowEditing” property. AllowEditing column api is used to enable or disable editing for specific column.

$("#Grid").ejGrid({

. . . . . . . .

columns: [

{ field: "EmployeeID", headerText: 'Employee ID', textAlign: ej.TextAlign.Right, width: 80, allowEditing: false },

]

. . . . . . .

});

We have created a sample and the same can be downloaded from the following location:

Sample Link: http://www.syncfusion.com/downloads/support/directtrac/general/Grid_(2)264412475.zip

Please refer to the link below for how we can use AllowEditing property for grid columns.

Online Documentation Link: http://helpjs.syncfusion.com/js/api/ejgrid#members:columns-allowediting

Please try the above sample and let us know if it helps.

Regards,

Isuriya R




BR Bruno Rodrigues August 4, 2015 08:26 PM UTC

Hi,
You didn't understand my problem.

Is not the field that must be disabled. It's a field with a specific value type.

For example. If I have a field with a Value > 0 It can be edited. If the Value < 0 It cannot.

Did I make myself clear?

But thank you very much for your answer :)


IR Isuriya Rajan Syncfusion Team August 5, 2015 12:27 PM UTC

Hi Bruno,

Sorry about the inconvenience caused.

You can edit particular value filed in a row by enabling the batch editing in Grid. Your requirement can be achieved by CellEdit event, which will trigger once we edit the particular cell in the Grid. In that event we can able to check the condition and disable the edit operation for the specific cell.

$("#Grid").ejGrid({

               

                editSettings: { allowEditing: true, allowAdding: true, allowDeleting: true,editMode:"batch" },

               

                      . . . . . . .      

            cellEdit: function (args) {

                   if(args.value <= 3) // Can check the condition

                          args.cancel =true; // Disable the edit for a cell

                                   }

            });

We have created a sample and the same can be downloaded from the following location:

Sample Link: http://www.syncfusion.com/downloads/support/directtrac/119798/Grid1138322670.zip

Please try the above sample and let us know if it helps. If we misunderstood your query, please provide us clear information regarding your requirements. It will help us to provide the prompt solution.

Regards,

Isuriya R




BR Bruno Rodrigues August 5, 2015 08:45 PM UTC

Isuriya Rajan,
thank you very much for your fast reply!
That's what I needed! Thank you!


IR Isuriya Rajan Syncfusion Team August 6, 2015 09:53 AM UTC

Hi Bruno,
Thanks for the update.
Please get back to us if you have any further queries.
Regards,
Isuriya R



Loader.
Live Chat Icon For mobile
Up arrow icon