下面的代码是后台绑定到panel中Item的信息
{title:'2010年8月',id:'2010-8-1',disabledClass : 'x-item-disabled',overCls : 'x-item-disabled',xtype:'panel',Frame:false,html:'<div id=\'2010-8-1\' onmouseover=\'\' align=\'center\' style=\'cursor:hand;background-color: #ffcc66;height=100%;width=100%;margin:0 0 0 0;\'><font size=\'7\' color=\'#ff6699\'>1</font><br><font size=\'2\' color=\'#ff6699\'>星期日</font></div>',tools:[{id:'gear',qtip:'添加',visible:true,handler:setWorkStatus}]},
{title:'2010年8月',id:'2010-8-2',disabledClass : 'x-item-disabled',overCls : 'x-item-disabled',xtype:'panel',Frame:false,html:'<div id=\'2010-8-2\' onmouseover=\'\' align=\'center\' style=\'cursor:hand;background-color: #ffcc66;height=100%;width=100%;margin:0 0 0 0;\'><font size=\'7\' color=\'#f1f1f1\'>2</font><br><font size=\'2\' color=\'#f1f1f1\'>星期一</font></div>',tools:[{id:'gear',qtip:'添加',visible:true,handler:setWorkStatus}]}每个信息有个函数setWorkStatus当我点击这个函数的时候
如何获取当前panel的id
例如第一个是id:'2010-8-1'
这个是动态读取的
最后将这个值传递给Iframe
var tabs2 = new Ext.TabPanel({
//默认显示一个panel,也就是Title为:加班申请的
activeTab: 0,
width:'100%',
autoHeight:true,
plain:true,
defaults:{autoScroll: true},
items:[{
title: '加班申请',
html: '<iframe scrolling="auto" frameborder="0" width="100%" height="260px" src="../../WebUI/AdditionalWork/OvertimeForm.aspx"> </iframe>'
},{
title: '请假申请',
html: ' <iframe scrolling="auto" frameborder="0" width="100%" height="380px" src="../../WebUI/AdditionalWork/LeaveWorkForm.aspx"> </iframe>'
}
]
});
{title:'2010年8月',id:'2010-8-1',disabledClass : 'x-item-disabled',overCls : 'x-item-disabled',xtype:'panel',Frame:false,html:'<div id=\'2010-8-1\' onmouseover=\'\' align=\'center\' style=\'cursor:hand;background-color: #ffcc66;height=100%;width=100%;margin:0 0 0 0;\'><font size=\'7\' color=\'#ff6699\'>1</font><br><font size=\'2\' color=\'#ff6699\'>星期日</font></div>',tools:[{id:'gear',qtip:'添加',visible:true,handler:setWorkStatus}]},
{title:'2010年8月',id:'2010-8-2',disabledClass : 'x-item-disabled',overCls : 'x-item-disabled',xtype:'panel',Frame:false,html:'<div id=\'2010-8-2\' onmouseover=\'\' align=\'center\' style=\'cursor:hand;background-color: #ffcc66;height=100%;width=100%;margin:0 0 0 0;\'><font size=\'7\' color=\'#f1f1f1\'>2</font><br><font size=\'2\' color=\'#f1f1f1\'>星期一</font></div>',tools:[{id:'gear',qtip:'添加',visible:true,handler:setWorkStatus}]}每个信息有个函数setWorkStatus当我点击这个函数的时候
如何获取当前panel的id
例如第一个是id:'2010-8-1'
这个是动态读取的
最后将这个值传递给Iframe
var tabs2 = new Ext.TabPanel({
//默认显示一个panel,也就是Title为:加班申请的
activeTab: 0,
width:'100%',
autoHeight:true,
plain:true,
defaults:{autoScroll: true},
items:[{
title: '加班申请',
html: '<iframe scrolling="auto" frameborder="0" width="100%" height="260px" src="../../WebUI/AdditionalWork/OvertimeForm.aspx"> </iframe>'
},{
title: '请假申请',
html: ' <iframe scrolling="auto" frameborder="0" width="100%" height="380px" src="../../WebUI/AdditionalWork/LeaveWorkForm.aspx"> </iframe>'
}
]
});
alert(panelId);
}{
title: '2010年8月',
id: '2010-8-1',
disabledClass: 'x-item-disabled',
overCls: 'x-item-disabled',
xtype: 'panel',
Frame: false,
html: '<div id=\'2010-8-1\' onmouseover=\'\' align=\'center\' style=\'cursor:hand;background-color: #ffcc66;height=100%;width=100%;margin:0 0 0 0;\'><font size=\'7\' color=\'#ff6699\'>1</font><br><font size=\'2\' color=\'#ff6699\'>星期日</font></div>',
tools: [{
id: 'gear',
qtip: '添加',
visible: true,
handler: function(event, toolEl, panel, tc) {
setWorkStatus(panel.id)
}
}]
},
alert(panelId);
//这里就可以传到iframe中了
}
var tabs2 = new Ext.TabPanel({
//默认显示一个panel,也就是Title为:加班申请的
activeTab: 0,
width:'100%',
.....
});el.on("click", function (){
Ext.apply(tabs2, {id: "yourID"});//yourID是你要添加的id
}); Ext.apply方法会向参数tabs2中,添加后面传递的参数对象
eg:
var u = {name: 'aa', age: 19};
alert(Ext.encode(u));
Ext.apply(u, {sex: true, address: 'china'});
alert(Ext.encode(u));//发现什么了,是不是多了sex、address属性
Ext.applyIf(u, {sex: false, birthday: '2999-09-09'});
alert(Ext.encode(u));//发现什么了,是不是多了birthday属性;sex值没有发生变化,因为是sex已经存在所以才不添加
Ext.applyIf if就是判断下再添加,判断后面的参数在添加的对象是否存在,如果存在就不添加,不存在的就
添加进去
//Ext.apply(tabs2,{id:panelId});
Ext.getCmp("hiddenid").setValue(panelId);
CurrentDate=Ext.getCmp('hiddenid').getValue();
//这个地方获取了 当前时间的值
Ext.Msg.alert('hello',CurrentDate); AdditionalWork.show();
};
但是我这里得不到那个值怎么回事? items:[{
title: '加班申请',
html: '<iframe name="work" scrolling="auto" frameborder="0" width="100%" height="260px" src="../../WebUI/AdditionalWork/OvertimeForm.aspx?Date='+CurrentDate +'"> </iframe>'
}
Iframe中参数Date为undefine
var tabs2 = new Ext.TabPanel({
//默认显示一个panel,也就是Title为:加班申请的
activeTab: 0,
width:'100%',
autoHeight:true,
plain:true,
defaults:{autoScroll: true},
items:[{
title: '加班申请',
html: '<iframe name="work" scrolling="auto" frameborder="0" width="100%" height="260px" src="../../WebUI/AdditionalWork/OvertimeForm.aspx?Date='+CurrentDate +'"> </iframe>'
},{
title: '请假申请',
html: ' <iframe scrolling="auto" frameborder="0" width="100%" height="380px" src="../../WebUI/AdditionalWork/LeaveWorkForm.aspx"> </iframe>'
}
]
});
var AdditionalWork=new Ext.Window({
title:'附加工作申请',
autoHeight:true,
width:'100%',
//通过偏移到零下区域进行隐藏
closeAction:'hide',
items:tabs2
}); var setWorkStatus=function(panelId){
CurrentDate=panelId;
AdditionalWork.show();
};
CurrentDate=panelId;
AdditionalWork.show();
};
这里CurrentDate我用alert取出来确实
是我要的值但是html: '<iframe name="work" scrolling="auto" frameborder="0" width="100%" height="260px" src="../../WebUI/AdditionalWork/OvertimeForm.aspx?Date='+CurrentDate +'"> </iframe>'
中currentDate为undifined
//默认显示一个panel,也就是Title为:加班申请的
activeTab: 0,
width:'100%',
autoHeight:true,
plain:true,
cDate: "",
defaults:{autoScroll: true},
items:[{
title: '加班申请',
html: '<iframe name="work" scrolling="auto" frameborder="0" width="100%" height="260px" src="../../WebUI/AdditionalWork/OvertimeForm.aspx?Date='+this.cDate+'"> </iframe>'
},{
title: '请假申请',
html: ' <iframe scrolling="auto" frameborder="0" width="100%" height="380px" src="../../WebUI/AdditionalWork/LeaveWorkForm.aspx"> </iframe>'
}
]
});
tabs2.cDate = "121212";
换成tabs2.cDate应该可以
var tabs2 = new Ext.TabPanel({
//默认显示一个panel,也就是Title为:加班申请的
activeTab: 0,
width:'100%',
autoHeight:true,
plain:true,
defaults:{autoScroll: true},
items:[{
title: '加班申请',
html: '<iframe name="work" scrolling="auto" frameborder="0" width="100%" height="260px" src="../../WebUI/AdditionalWork/OvertimeForm.aspx?Date='+CurrentDate +'"> </iframe>'
},{
title: '请假申请',
html: ' <iframe scrolling="auto" frameborder="0" width="100%" height="380px" src="../../WebUI/AdditionalWork/LeaveWorkForm.aspx"> </iframe>'
}
]
});就执行了,CurrentDate 当然没值 你可以给 iframe 指定id然后改变它的src 属性即可
我这边没有问题啊
那你就把html后面的代码定义全局的,赋值算了
我ls写的这些方法都是可以的,lz的怎么不行
主要js运行是有先后顺序的,赋值代码放在你的取值代码运行顺序的前面
我这个弄了下
采用更改Iframe的src属性来改变参数值
var setWorkStatus=function(panelId){ Ext.getCmp("hiddenid").setValue(panelId);
CurrentDate=Ext.getCmp('hiddenid').getValue();
//这里报错 Ext.getDom()为空或者不是对象
Ext.getDom('work').src='../../WebUI/AdditionalWork/OvertimeForm.aspx?Date='+panelId;
AdditionalWork.show();
};
var tabs2 = new Ext.TabPanel({
//默认显示一个panel,也就是Title为:加班申请的
activeTab: 0,
width:'100%',
autoHeight:true,
plain:true,
cDate:"",
defaults:{autoScroll: true},
items:[{
id:'work',
title: '加班申请',
html: '<iframe id="work" scrolling="auto" frameborder="0" width="100%" height="260px" src="../../WebUI/AdditionalWork/OvertimeForm.aspx"> </iframe>'
},{
title: '请假申请',
html: ' <iframe scrolling="auto" frameborder="0" width="100%" height="380px" src="../../WebUI/AdditionalWork/LeaveWorkForm.aspx"> </iframe>'
}
]
});
感谢大家
这样写即可 var setWorkStatus=function(panelId){
var AdditionalWork=new Ext.Window({
title:'附加工作申请',
autoHeight:true,
width:'100%',
//通过偏移到零下区域进行隐藏
closeAction:'hide',
//关闭windows之后增加监听事件
// listeners : {'hide':{fn: makesure}},
items:
[
new Ext.TabPanel({
//默认显示一个panel,也就是Title为:加班申请的
activeTab: 0,
width:'100%',
autoHeight:true,
plain:true,
defaults:{autoScroll: true},
items:
[{
title: '加班申请',
html: '<iframe id="work" scrolling="auto" frameborder="0" width="100%" height="260px" src="../../WebUI/AdditionalWork/OvertimeForm.aspx?Date='+panelId+'"> </iframe>'
}
,{
title: '请假申请',
html: ' <iframe scrolling="auto" frameborder="0" width="100%" height="380px" src="../../WebUI/AdditionalWork/LeaveWorkForm.aspx"> </iframe>'
}
]
})
]
})
AdditionalWork.show();
};