dobs
dobs

Reputation: 2764

extjs disable cell editing

How I can disable specific cell editing from xml data file?

like this:

<price disabled="true">9.37</price>

Please give me examples Thanks in advance

Upvotes: 0

Views: 7133

Answers (1)

egerardus
egerardus

Reputation: 11486

First off, to read attributes from XML response you need to include a field in your model that has a mapping config to the attribute, see this post. In your case something like this:

Ext.define('yourApp.model.Price', {
    extend: 'Ext.data.Model',
    fields: [
        {name: 'price',     type: 'float'},
        {name: 'disabled',  type: 'boolean',  mapping: 'price/@disabled'}
    ]
});

It's been awhile since I've used XML response so you may have to play around with that a bit.

Then you should simply include a check in your gridpanel's beforeedit event to prevent editing if the record's disabled field is true.

If you are using the MVC pattern it would be something like this:

// controllers init function
init: function() {

    this.control({

        'yourgridpanel': {

            // prevent disabled edits
            beforeedit: function(plugin, edit) {

                if (edit.record.get('disabled')) {
                    return false;
                }
            }
        }
    });
}

If you are not using an MVC pattern the handler would go something like this:

yourGridPanel.on('beforeedit', function(plugin, edit) {
    if (edit.record.get('disabled')) {
        return false;
    }
});

Upvotes: 4

Related Questions