PDA

View Full Version : Enable text selection by a button



ragecf
24 Jan 2013, 1:31 AM
Hey all,

Sorry for asking this question again. I want to enable/disable grid text selection by a button.

Someone provided a solution:



Ext.create('Ext.data.Store', {
storeId:'simpsonsStore',
fields:['name', 'email', 'phone'],
data:{'items':[
{ 'name': 'Lisa', "email":"lisa@simpsons.com", "phone":"555-111-1224" },
{ 'name': 'Bart', "email":"bart@simpsons.com", "phone":"555-222-1234" },
{ 'name': 'Homer', "email":"home@simpsons.com", "phone":"555-222-1244" },
{ 'name': 'Marge', "email":"marge@simpsons.com", "phone":"555-222-1254" }
]},
proxy: {
type: 'memory',
reader: {
type: 'json',
root: 'items'
}
}
});


Ext.create('Ext.grid.Panel', {
title: 'Simpsons',
store: Ext.data.StoreManager.lookup('simpsonsStore'),
columns: [
{ text: 'Name', dataIndex: 'name' },
{ text: 'Email', dataIndex: 'email', flex: 1 },
{ text: 'Phone', dataIndex: 'phone' }
],
height: 200,
width: 400,
renderTo: Ext.getBody()
, tbar: [{
text: 'Enable Selection'
, enableToggle: true
, toggleHandler: function (btn, pressed) {
var v = btn.up('grid').view.el;

v.selectable();
}
}]
});


grid.view.el.selectable()/unselectable();

This is good solution in FF but can't work in chrome and IE8.

Someone can solve it? thanks.

mitchellsimoens
28 Jan 2013, 12:29 PM
grid.getView().el.unselectable();
grid.getView().el.unselectable();

ragecf
28 Jan 2013, 10:17 PM
grid.getView().el.unselectable();
grid.getView().el.unselectable();


Thank you for your reply.

I tested grid.getView().el.selectable(), it only works in FF, cannot work in Chrome and ie8 (both in winxp and win7).

And I checked source code for getView(), I thank it is the same to grid.view.el.selectable();