初学Extjs问题?TBar中的tooltip显示不出来?

fenglik 2011-04-14 12:43:04
为什么tooltip无效,显示不出来?没搞明白!呵呵,请大家指点下?

Ext.onReady(function(){

// create the Data Store
var store = new Ext.data.JsonStore({
root: 'Products',
totalProperty: 'totalCount',
idProperty: 'ProductID',
remoteSort: true,
//sortInfo:{field: 'ProductID', direction: 'ASC'}
fields: [
{name: 'ProductID', type: 'int'} , 'ProductName', 'QuantityPerUnit'
],

// load using script tags for cross domain, if the data in on the same domain as
// this page, an HttpProxy would be better
proxy: new Ext.data.HttpProxy({
//url: 'http://extjs.com/forum/topics-browse-remote.php'
url: 'http://localhost/Asp/ext-3.2.1/MyTools/HttpProxy/GetNorth.asp'
})
});


store.setDefaultSort('ProductID', 'asc');


// pluggable renders
function renderTopic(value, p, record){
return String.format(
'<b><a href="http://extjs.com/forum/showthread.php?t={2}" target="_blank">{0}</a></b><a href="http://extjs.com/forum/forumdisplay.php?f={3}" target="_blank">{1} Forum</a>',
value, record.data.forumtitle, record.id, record.data.forumid);
}
function renderLast(value, p, r){
return String.format('{0}<br/>by {1}', value.dateFormat('M j, Y, g:i a'), r.data['lastposter']);
}


var sm2 = new Ext.grid.CheckboxSelectionModel({
listeners: {
// On selection change, set enabled state of the removeButton
// which was placed into the GridPanel using the ref config
selectionchange: function(sm) {
if (sm.getCount()) {
grid.removeButton.enable();
} else {
grid.removeButton.disable();
}
}
}
});


var grid = new Ext.grid.GridPanel({

// inline toolbars
tbar:[{
text:'新增',
tooltip:'新增记录',
iconCls:'add'
}, '-', {
text:'修改',
tooltip:'修改记录',
iconCls:'option'
},'-',{
text:'删除',
tooltip:'删除记录',
iconCls:'remove',

// Place a reference in the GridPanel
ref: '../removeButton',
disabled: true
},'-',{
xtype:'textfield',
id:'KeyWord',
width:100,
title:'请输入关键词'
},'-',{
xtype:'combo',
store: store,
fieldLabel: '请选择分类',
valueField :"ProductID",
displayField: "ProductID",
mode: 'local',
forceSelection: true,//必须选择一项
emptyText:'请选择分类',//默认值
hiddenName:'ProductID',//hiddenName才是提交到后台的input的name
editable: false,//不允许输入
triggerAction: 'all',//因为这个下拉是只能选择的,所以一定要设置属性triggerAction为all,不然当你选择了某个选项后,你的下拉将只会出现匹配选项值文本的选择项,其它选择项是不会再显示了,这样你就不能更改其它选项了。
//allowBlank:false,//该选项值不能为空
id : 'SelContent',
width:100,
name: 'parent',
listeners:{
select : function(combo, record,index){
store.proxy= new Ext.data.HttpProxy({url: 'http://localhost/Asp/ext-3.2.1/MyTools/HttpProxy/GetNorth.asp?SelContent=' + combo.value});
store.load({params:{start:0, limit:15}});
}
}
},'-',{
text:'搜索',
handler : function() {
var KeyWord= document.getElementById("KeyWord").value;
var SelContent= document.getElementById("SelContent").value;
// 定义进度条
//grid.body.mask('正在查询,请稍等......');
//alert('http://localhost/Asp/ext-3.2.1/MyTools/HttpProxy/GetNorth.asp?KeyWord=' + KeyWord + '&SelContent=' + SelContent);

store.proxy= new Ext.data.HttpProxy({url: 'http://localhost/Asp/ext-3.2.1/MyTools/HttpProxy/GetNorth.asp?KeyWord=' + KeyWord + '&SelContent=' + SelContent});
store.load({params:{start:0, limit:15}});
}
}],

width:700,
height:500,
title:'列表显示',
store: store,
trackMouseOver:true,
disableSelection:true,
loadMask: true,
sm: sm2,
// grid columns
columns:[
new Ext.grid.RowNumberer(),
sm2,
{
id: 'RowID', // id assigned so we can apply custom css (e.g. .x-grid-col-topic b { color:#333 })
header: "ProductID",
dataIndex: 'ProductID',
width: 60,
//renderer: renderTopic,
align: 'center',
sortable: true
},{
header: "ProductName",
dataIndex: 'ProductName',
width: 150,
align: 'center',
sortable: true
},{
header: "QuantityPerUnit",
dataIndex: 'QuantityPerUnit',
width: 250,
align: 'center',
sortable: true
}],

// customize view config
viewConfig: {
forceFit:true,
enableRowBody:true,
showPreview:false,
getRowClass : function(record, rowIndex, p, store){
if(this.showPreview){
p.body = '<p>'+record.data.excerpt+'</p>';
return 'x-grid3-row-expanded';
}
return 'x-grid3-row-collapsed';
}
},

// paging bar on the bottom
bbar: new Ext.PagingToolbar({
pageSize: 15,
store: store,
displayInfo : true,
beforePageText:"第 ",
afterPageText:" 页/共 {0} 页",
firstText:"首页",
prevText:"上一页",
nextText:"下一页",
lastText:"尾页",
refreshText:"刷新",
displayMsg : "当前显示记录从 {0} - {1} 总共 {2} 条记录",
emptyMsg : "没有相关记录!"//,
/* items:[
'-', {
pressed: true,
enableToggle:true,
text: 'Show Preview',
cls: 'x-btn-text-icon details',
toggleHandler: function(btn, pressed){
var view = grid.getView();
view.showPreview = pressed;
view.refresh();
}
}]*/
})
});

// render it
grid.render('topic-grid');

// trigger the data store load
store.load({params:{start:0, limit:15}});
});

[/code]
...全文
1494 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
x642740020 2012-08-07
  • 打赏
  • 举报
回复
同样问题 急需急需
likeajin 2011-04-16
  • 打赏
  • 举报
回复
楼主的意思是想给一个文本框(xtype='textfield')添加上tooltip吗?如果是的话可以试着在渲染完毕事件中新建一个tooltip对象。这是一个通式。

new Ext.ToolTip({
target : documentElement.id,//需要提示的目标dom元素
html : '提示信息',//想要显示的提示信息
trackMouse : true//是否跟随鼠标移动而移动
});

注:以上代码中target需要解释,值最常见的情况如下:
1.任何一个dom元素(非Ext元素),即可以通过document.getElementBy……系列方法获取到的元素。将target设置为dom元素ID。
2.如果是一个Ext元素,即可以通过Ext.getCmp(element.id)获取到的元素。需要将target设置为该元素的dom元素的ID,通过Ext.getCmp(element.id).getEl()获取。
fenglik 2011-04-15
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 dataminer_2007 的回复:]
引用 5 楼 fenglik 的回复:
引用 3 楼 kk3k2005 的回复:
Ext.QuickTips.init();
代码里加上这句看看

加上这句tooltip其他的可以显示了,但这个xtype:'textfield', id:'KeyWord',怎么让他显示,tooltip好像没用啊,是不是用其他的属性设置?有没有参考手册什么的?苦恼啊?

多看看 API 文档和 examples 文件夹里的例子
[/Quote]
有看,API文档还不是很懂,例子的话超出例子显示效果范围就没有办法,只能baidu,耗时间,效率很差啊
fenglik 2011-04-14
  • 打赏
  • 举报
回复
grid 行的高度,可以改吗?
这句什么意思 grid.render('topic-grid');
dataminer_2007 2011-04-14
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 fenglik 的回复:]
引用 3 楼 kk3k2005 的回复:
Ext.QuickTips.init();
代码里加上这句看看

加上这句tooltip其他的可以显示了,但这个xtype:'textfield', id:'KeyWord',怎么让他显示,tooltip好像没用啊,是不是用其他的属性设置?有没有参考手册什么的?苦恼啊?

另外如何设置combo,emptytext:'请选择分类'时fieldv……
[/Quote]
多看看 API 文档和 examples 文件夹里的例子
怀念十月 2011-04-14
  • 打赏
  • 举报
回复
 //任务类型
ajaxObj.AddParams('type', 'jobtype');
var a = Ext.util.JSON.decode(ajaxObj.GetData());
a[0].unshift(["", "所有"])//在这里可以上他开始的时候就为""
var storeJobType = new Ext.data.SimpleStore({
fields: ['value', 'text'],
data: a[0]
});
//任务类型下拉框
var CbxJobType = new Ext.form.ComboBox({
fieldLabel: '任务类型',
anchor: '100%',
triggerAction: 'all',
store: storeJobType,
mode: 'local',
displayField: 'text',
valueField: 'value',
emptyText: '请选择',
editable: false
});
se7en 2011-04-14
  • 打赏
  • 举报
回复
http://www.sencha.com/
fenglik 2011-04-14
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 kk3k2005 的回复:]
Ext.QuickTips.init();
代码里加上这句看看
[/Quote]
加上这句tooltip其他的可以显示了,但这个xtype:'textfield', id:'KeyWord',怎么让他显示,tooltip好像没用啊,是不是用其他的属性设置?有没有参考手册什么的?苦恼啊?

另外如何设置combo,emptytext:'请选择分类'时fieldvalue值为空?
dataminer_2007 2011-04-14
  • 打赏
  • 举报
回复
Ext.QuickTips.init(); 正解

grid 行高度可以去 ext-all.css 中改

.x-grid3-row td,.x-grid3-summary-row td{
height:30px;
line-height:30px;
.........
}
KK3K2005 2011-04-14
  • 打赏
  • 举报
回复
Ext.QuickTips.init();
代码里加上这句看看
夜雨山庄 2011-04-14
  • 打赏
  • 举报
回复
grid.render('topic-grid');
的意思是,把这个GRID添加进ID为'topic-grid'的容器里。
'topic-grid'可能是一个DIV,或者其它什么的。

52,797

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Ajax
社区管理员
  • Ajax
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧