var store=Ext.create('Ext.data.ArrayStore', {
fields:['name','email','phone'],
data:[
['testone','testone@.com','123123123'],
['testtwo','testtwo@.com','456456456'],
['testthere','testthere@.com','789789789'],
['testfour','testfour@.com','123456789'],
['testfive','testfive@.com','987654321']
]
});
var grid=Ext.create('Ext.grid.Panel', {
title:'tooltip study',
width:400,
height:200,
store:store,
renderTo:'tooltip',
columns:[{
header:'姓名',
dataIndex:'name',
flex:1
},{
header:'郵箱',
dataIndex:'email',
flex:1
},{
header:'電話',
dataIndex:'phone',
flex:1
}],
tbar:[{
text:'save'
},'->',{
text:'select',
id:'select'
}]
});
grid.getView().on('render', function(view) {
view.tip=Ext.create('Ext.tip.ToolTip', {
target:view.el,//target 值爲元素或是id
delegate:view.itemSelector,
trackMouse:true,
renderTo:'tooltip',
listeners: {
beforeshow: function(tip) {
tip.update(view.getRecord(tip.triggerElement).get('email'));
}
}
})
});
var tip=Ext.create('Ext.tip.ToolTip', {
target:'select',
html:'select one row',
autoHide:true,//自動隱藏
showDelay:100,
hideDelay:200,
dismissDelay :0,
trackMouse:false,//true:隨着鼠標移動
mouseOffSet:[60,60],//從鼠標位置開始偏移(X/Y)
anchor:'right',//top,right,bottom,left
anchorToTarget:true,//false時,用anchor對齊,true時,用defaultAlign(默認值: "tl-bl?")對齊
defaultAlign:'t-b?',
anchorOffset:10,//anchor的值是top或bottom時,anchor arrow水平偏移;anchor值是left或right時,nchor arrow豎直偏移
closable : true,//有關閉按鈕
draggable: true//能夠拖動
})
<script type="text/javascript">
Ext.onReady( function() {
Ext.tip.QuickTipManager.init();//初始化全局的QuickTips,爲建立QuickTips作準備
Ext.apply(Ext.tip.QuickTipManager.getQuickTip(), {
maxWidth:300,
minwidth:500,
showDelay:50,
hideDelay:50,
trackMouse:true,
dismissDelay:1000
});
Ext.create('Ext.panel.Panel', {
id:'test_panel',
title:'quicktip study',
width:200,
height:150,
renderTo:'quicktip'
});
Ext.tip.QuickTipManager.register({//Ext.tip.QuickTipManager.tips註冊一個QuickTips
target:'test_panel',
title:'tooltip',
text:'this tooltip was added in code',
width:100,
dismissDelay:10000,//(重寫QuickTips的config中的dismissDelay)
autoHide:true,
cls:''
});
})
</script>
</head>
<body>
<div id="quicktip" style="padding:30px;">
</div>
<input type="button" value="OK" data-qtitle="OK Button" data-qwidth="100"
data-qtip="This is a quick tip from markup!" data-qclass="padding:30px;">
</input>
</body>