ExtJS 使用点滴 六 如何设置EditorGridPannel 中特定行的只读属性

Ext.onReady(function(){

    Ext.QuickTips.init();
   
    var fm = Ext.form,Ed = Ext.grid.GridEditor;
    var sm = new Ext.grid.CheckboxSelectionModel(); 
    
    var cm = new Ext.grid.ColumnModel({
    columns: [
        {
            header: "Leaf Class",
               dataIndex: 'partCat',
               width: 120,
               align: 'left'
        },{
               header: "Shown on Drawing ?",
               dataIndex: 'shownonDrawing',
               width: 160,
               align: 'center',

               editor: new Ed(new Ext.form.ComboBox({
                typeAhead: true,
                   triggerAction: 'all',
                   transform:'Drwaing',               
                   lazyRender:true
             }))
        },{
            header: "Drawing Number",
               dataIndex: 'drawingNumber',
               width: 160,
               align: 'center',

               editor: new fm.TextField({
                allowBlank: false,
                 allowNegative: false,
                   maxValue: 100000
             })
         }],
    isCellEditable: function(col, row) {
        var record = ds.getAt(row);
        if (record.get('shownonDrawing') == 'Same As New Part') {
            return false;
        }
        return Ext.grid.ColumnModel.prototype.isCellEditable.call(this, row, col);
    }
    });

    // by default columns are sortable
    cm.defaultSortable = true;
    
    var Plant = Ext.data.Record.create([
          {name: 'partCat'},
          {name: 'shownonDrawing'},
          {name: 'drawingNumber'}
      ]);

    // create the Data Store
    var ds = new Ext.data.Store({
        url: 'PartAttributes.xml',
        reader: new Ext.data.XmlReader({
               record: 'partattrDesc'
        }, Plant),

        sortInfo:{field:'nounname', direction:'ASC'}
    });

    // create the editor grid
    var griPI = new Ext.grid.EditorGridPanel({
        ds: ds,
        cm: cm,
        sm: sm,
        renderTo: 'partAttributes',
        width:800,
        height:400,
        frame:true,
        clicksToEdit:1,
        tbar: [{
            text: ' Save as Draft  ',
            iconCls: 'Save as Draft',
            id: 'Save as Draft',
            handler: function(){
            }
        },'-',{
            text: ' Next  ',
            iconCls: 'Next',
            id: 'Next',
            handler: function(){
        window.open("some.jsp","_self")
            }
        },'-',{
            text: ' Cancel  ',
            iconCls: 'Cancel',
            id: 'Cancel'
        }
        ]
    });

    // trigger the data store load
    ds.load();
});
posted @ 2012-09-15 22:13  FredTang  Views(2621)  Comments(0Edit  收藏  举报