jsgrid icon indicating copy to clipboard operation
jsgrid copied to clipboard

How do we PREVENT editing from occurring in a grid that's marked as editing:true?

Open brichardson2013 opened this issue 8 years ago • 2 comments

I have a grid that contains a column that may or may not be editable, based on another column's value. I can set readonly on the cell where appropriate, but I would rather just PREVENT the user from even editing the cell if the row is not supposed to be editable. (I.E., not even show the editable text field.) Here's the field definitions as I've written them:

	fields: [
		{name: "serviceid", title: "ServiceId", type: "text", visible: false },
		{name: "service", width: 200, title: "Service", type: "text", editing: false },
		{name: "additional_info", width: 300, title: "Additional Info", type: "text", 
        editTemplate: function(value, item) {
                var $result = jsGrid.fields.text.prototype.editTemplate.apply(this, arguments);
                if(item.additionalfield == true)
                {
                    $result.prop("readOnly", false );
                }
                else
                {
                    $result.prop("readOnly", true);

// THIS IS WHERE I'D PREFER TO PREVENT EDITING INSTEAD OF JUST SETTING READONLY TRUE

                }
                
                return $result;                    
            }
        },
        {name: "additionalfield", width: 10, title: "Info Required", type: "text", visible: false },
        {type: "control" }
	]

Any help is appreciated!

brichardson2013 avatar Jul 31 '18 15:07 brichardson2013

I've answered my own question,,, use onItemEditing:

    onItemEditing: function(args) {
        if(args.item.additionalfield == false) {
            args.cancel = true;
        }
    },

brichardson2013 avatar Jul 31 '18 16:07 brichardson2013

@brichardson2013 @tabalinas

I have editing true for Grid and Editing false for a column which has Item and Edit Template defined. Still when edit the grid, that column which has editing false also get editable.

No other settings are defined and nothing else. I have tried the solution on this link but it stops the complete editing for all columns. Means on the click of edit icon, nothing happens at all which I don't want.

I just want to make one column non editable which has item and edit template defined with Editing false setting.

anki7scorp avatar Sep 09 '23 14:09 anki7scorp