EXTJS7實(shí)現(xiàn)點(diǎn)擊拖拉選擇文本
本文實(shí)例為大家分享了EXTJS7實(shí)現(xiàn)點(diǎn)擊拖拉選擇文本的具體代碼,供大家參考,具體內(nèi)容如下
默認(rèn)情況下,用戶(hù)無(wú)法通過(guò)點(diǎn)擊拖拉選擇界面上的文本
解決方案
Ext.Component組件可以使用userSelectable配置項(xiàng),設(shè)置為‘text',即可實(shí)現(xiàn)此組件中文本的點(diǎn)選
注意:如果設(shè)置為true,等效于設(shè)置樣式 user-select: auto; ,將根據(jù)瀏覽器默認(rèn)屬性進(jìn)行選擇
{
xtype: 'grid',
userSelectable: 'text'
}
也可以傳入對(duì)象設(shè)置子元素的樣式
userSelectable: {
element: true, // allow the element to be user selectable
bodyElement: true // allow the component's body element to be user selectable
}
非Ext.Component組件可以使用userCls配置項(xiàng),添加 Ext.baseCSSPrefix + ‘user-selectable-text' 樣式類(lèi)
{
xtype: 'grid',
columns: [{
cell: { userCls: Ext.baseCSSPrefix + 'user-selectable-text' }
}]
}
源碼解析
Ext.define('Ext.Component', {
// userSelectable 各屬性值對(duì)應(yīng)的樣式類(lèi)
userSelectableClsMap: {
true: Ext.baseCSSPrefix + 'user-selectable-auto',
false: Ext.baseCSSPrefix + 'user-selectable-none',
all: Ext.baseCSSPrefix + 'user-selectable-all',
auto: Ext.baseCSSPrefix + 'user-selectable-auto',
text: Ext.baseCSSPrefix + 'user-selectable-text',
none: Ext.baseCSSPrefix + 'user-selectable-none'
},
updateUserSelectable: function(newSelectable, oldSelectable) {
var me = this,
map = me.userSelectableClsMap,
el = me.el,
name, childEl;
if (typeof oldSelectable === 'boolean' || typeof oldSelectable === 'string') {
el.removeCls(map[oldSelectable]);
}
else {
for (name in oldSelectable) {
childEl = me[name];
//<debug>
if (!childEl || !childEl.isElement) {
Ext.raise('Element not found: "' + name + '"');
}
//</debug>
childEl.removeCls(map[oldSelectable[name]]);
}
}
if (typeof newSelectable === 'boolean' || typeof newSelectable === 'string') {
// 如果傳入為布爾或字符串,直接添加對(duì)應(yīng)的樣式類(lèi)
el.addCls(map[newSelectable]);
}
else {
// 如果傳入的是對(duì)象,則根據(jù)對(duì)象屬性分別給子元素添加樣式類(lèi)
for (name in newSelectable) {
childEl = me[name];
//<debug>
if (!childEl || !childEl.isElement) {
Ext.raise('Element not found: "' + name + '"');
}
//</debug>
childEl.addCls(map[newSelectable[name]]);
}
}
},
});
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
詳解JavaScript中map()和forEach()的異同
在JavaScript中,map()和forEach()是兩個(gè)常用的數(shù)組方法,它們都用于遍歷數(shù)組,但在某些方面有一些關(guān)鍵的區(qū)別,本文將詳細(xì)討論這兩種方法的異同,以幫助您更好地理解它們的用法和適用場(chǎng)景,需要的朋友可以參考下2024-02-02
js實(shí)現(xiàn)圖片輪播效果學(xué)習(xí)筆記
這篇文章主要為大家詳細(xì)介紹了js實(shí)現(xiàn)圖片輪播效果的學(xué)習(xí)筆記,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-07-07
使用JavaScript實(shí)現(xiàn)旋轉(zhuǎn)的彩圈特效
這篇文章主要介紹了使用JavaScript實(shí)現(xiàn)旋轉(zhuǎn)的彩圈特效的相關(guān)資料,需要的朋友可以參考下2015-06-06
JavaScript字符串的json的自定義加密解密函數(shù)示例
JavaScript自定義函數(shù)中使用String.fromCharCode函數(shù)將輸入字符串中每個(gè)字符的Unicode編碼加1,然后將加密后的字符拼接成一個(gè)新字符串返回,調(diào)用JSON.stringify函數(shù)轉(zhuǎn)換json成一個(gè)普通字符串2023-12-12
js對(duì)象實(shí)現(xiàn)數(shù)據(jù)分頁(yè)效果
這篇文章主要為大家詳細(xì)介紹了js對(duì)象實(shí)現(xiàn)數(shù)據(jù)分頁(yè)效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-09-09
淺談使用MVC模式進(jìn)行JavaScript程序開(kāi)發(fā)
這篇文章主要介紹了淺談使用MVC模式進(jìn)行JavaScript程序開(kāi)發(fā),同時(shí)也介紹了一些JavaScript的MVC框架,需要的朋友可以參考下2015-11-11

