2010-10-21 17 views
8

में पंक्तियों को अक्षम करने के लिए extjs ग्रिड में पंक्ति चयन को अक्षम कैसे करें।extjs ग्रिड

उत्तर

8

आपको अक्षम चयन संपत्ति को सत्य पर सेट करना होगा। यदि कोई चयन मॉडल निर्दिष्ट है तो इसका मान अनदेखा किया जाता है।

उदाहरण के लिए:

var grid = new Ext.grid.GridPanel({ 
    disableSelection: true, 
    store: new Ext.data.Store({ 
     reader: reader, 
     data: xg.dummyData 
    }), 
    columns: [ 
     {id:'company', header: "Company", width: 200, sortable: true, dataIndex: 'company'}, 
     {header: "Price", width: 120, sortable: true, renderer: Ext.util.Format.usMoney, dataIndex: 'price'}, 
     {header: "Change", width: 120, sortable: true, dataIndex: 'change'}, 
     {header: "% Change", width: 120, sortable: true, dataIndex: 'pctChange'}, 
     {header: "Last Updated", width: 135, sortable: true, renderer: Ext.util.Format.dateRenderer('m/d/Y'), dataIndex: 'lastChange'} 
    ], 
    viewConfig: { 
     forceFit: true, 

//  Return CSS class to apply to rows depending upon data values 
     getRowClass: function(record, index) { 
      var c = record.get('change'); 
      if (c < 0) { 
       return 'price-fall'; 
      } else if (c > 0) { 
       return 'price-rise'; 
      } 
     } 
    }, 
    width:600, 
    height:300, 
    frame:true, 
    title:'Framed with Checkbox Selection and Horizontal Scrolling', 
    iconCls:'icon-grid' 
}); 

आप केवल कुछ पंक्तियों के चयन को निष्क्रिय करना चाहते हैं, तो आप एक श्रोता SelectionModel को घटना "beforerowselect" जोड़ने और झूठे लौट सकते हैं जब आप एक पंक्ति होने के लिए नहीं करना चाहते हैं चयनित।

+1

धन्यवाद, लेकिन अगर मेरे पास चयन मॉडल भी है। – John

+0

क्या आप सभी पंक्तियों या कुछ पंक्तियों का चयन अक्षम करना चाहते हैं? – ncardeli

+0

मैं सभी पंक्तियों को – John

4

उपयोग इस config क्या आप ग्रिड

var grid = new Ext.grid.GridPanel({ 
    disableSelection: true, 
}); 
आप और

इस छोटे चाल RowSelectionModel में चयन को निष्क्रिय करने के

var grid = new Ext.grid.GridPanel({ 
    selModel : new Ext.grid.RowSelectionModel({selectRow: Ext.emptyFn}) 
}); 
1

आप के लिए एक और चाल कर सकते हैं के लिए एक चयन मॉडल नहीं है, तो आपका ग्रिड इस तरह दिखता है:

grid.getSelectionModel().lock(); 
+0

बहुत अच्छा धन्यवाद – durtto

संबंधित मुद्दे