/*
	Modyfikacja Ext.grid.ColumnModel umożliwiająca blokowanie (przed edycją) 
	wybranych komórek i/lub wierszy.
	@author Piotr Krokowski
	@copyright LGPL
	
	Sposób użycia jest następujący:
	- dla grid'a, w którym chcemy zastosować możliwość blokowania wierszy przed edycją, należy użyć
		metody registerStore (na ColumnModel) i podać referencję do store'a
	- do oceny czy wiersz jest edytowalny używane są kolumny notEditable danych (row.data.notEditable) 
	  dla każdego wiersza danych ze store'a
	- jeżeli notEditable nie jest ustawione, to wartość jest ignorowana (tylko notEditable==true daje skutek)
*/

Ext.override(Ext.grid.ColumnModel, {
	storeReference: null,
	/**
     * Returns true if the cell is editable.
     * @param {Number} colIndex The column index
     * @param {Number} rowIndex The row index
     * @return {Boolean}
     */
    isCellEditable : function(colIndex, rowIndex){
        var isColumnEditable = (this.config[colIndex].editable || (typeof this.config[colIndex].editable == "undefined" && this.config[colIndex].editor)) ? true : false;
        var isRowEditable = true; // domyślnie
        try {
	        if (this.storeReference!=null) {
	        	var row = this.storeReference.getAt(rowIndex);
	        	if (row.data.notEditable)
	        		var isRowEditable = false;
	        }
        } catch(e) {
        	// console.warn(e);
        }
        return (isColumnEditable && isRowEditable);
    },
    registerStore: function (store) {
    	this.storeReference = store;
    }
});


