Monday, March 14, 2016

EXTJS: Disable row selection on grid

In a grid, there already is a selection model present. Grid panels use Ext.selection.RowModel by default.

But if there is a requirement to disable the selection model, here is what you can do.
 Ext.create('Ext.grid.Panel', {  
   renderTo: document.body,  
   store: userStore,  
   width: 400,  
   height: 200,  
   title: 'Application Users',  
   columns: [{  
     text: 'Name',  
     width: 100,  
     sortable: false,  
     hideable: false,  
     dataIndex: 'name'  
   }, {  
     text: 'Email Address',  
     width: 150,  
     dataIndex: 'email',  
     hidden: true  
   }],  
   listeners: {  
     beforeselect: function() {  
       return false;  
     }  
   }  
 });  

The below piece of code in the listener does the trick. It returns false because of which no action happens on click of any row.

 beforeselect: function() {  
   return false;  
 }  

Happy coding :)

No comments:

Post a Comment