Tuesday, 20 January 2015

Selection of Div Content on ExtJS(Select ALL)

Here is a simple code snippet to show data on view with select all enabled container.

Ext.create('Ext.window.Window', {
autoShow : true,
title : 'Demo - Select All on Div ',
width : '80%',
height : '80%',
layout : 'fit',
plain : true,
modal : true,
items : [{
xtype : 'panel',
autoScroll : true,
tbar : ['->', {
text : 'Select All',
iconCls : 'icon-copy',
handler : function(button) {
var operatorsummaryview = button.up('panel')
.down('#datacontainer');
var containerid = operatorsummaryview.id;
if (document.selection) {
var range = document.body.createTextRange();
range.moveToElementText(document
.getElementById(containerid));
range.select();
} else if (window.getSelection()) {
var range = document.createRange();
range.selectNode(document
.getElementById(containerid));
window.getSelection().removeAllRanges();
window.getSelection().addRange(range);
}
}
}],
items : [{
xtype : 'container',
itemId : 'datacontainer',
padding : '10 10 10 10',
style : {
backgroundColor : '#FFF'
},
html : valueTobeShown
}]
}]
});


No comments:

Post a Comment