Archive for the 'Javascript' Category

Javascript方式打开一个浏览器

Apr 23 2009 Published by Tony under Javascript

var newWindow
=window.open(
url,
'txtPopup',
'height=768,location=0,menubar=0,personalbar=0,scrollbars=1,status=0,toolbar=0,width=1024,resizable=0'
);
newWindow.focus();

javascript 刷新页面的方式:

  1. history.go(0)
  2. location.reload()
  3. location=location
  4. location.assign(location)
  5. document.execCommand(‘Refresh’)
  6. window.navigate(location)
  7. location.replace(location)
  8. document.URL=location.href

No responses yet

Ext.TabPanel遇到的问题与解决方法

Apr 17 2009 Published by Tony under Javascript

今天在Ext.form.FormPanel中嵌套TabPanel时,发现了这样一个问题:
创建了一个FormPanel,在这个Panel中需要以Tab的方式展现数据,每个TabPanel中包含一个FormPanel的字段。但是我发现在每次FormPaneel中的数据load完成之后,只有处于Active状态的Tab中的数据存在,而Active其他Tab后,数据都看不见,所以我怀疑是BasicForm装载数据的时候,这些处于非active状态的panel并没有创建出来。
解决办法:
在FormPanel中的Form装载完数据后,把这些出具备份到这个BasicForm中的一个属性中,比如result_data。之后在TabPanel的这些Field渲染的时候,判断result_data是否存在,如果存在,则把对应的字段值填进去。
示例代码:

//监听basicForm中的数据加载完成
new Ext.FormPanel({
listeners:{
actioncomplete:function(form,action){
if(action.type=="load"){
form.result_data=action.result.data
}
}
}
...
...
//formPanel中嵌套的tabPanel
{
xtype:'tabpanel',
activeTab: 0,
items : [{
title : track_window.column.text_what_has_been_done,
height : 180,
layout:'fit',
items:{//tabPanel中所包含的Form的字段
xtype : 'htmleditor',
name : 'progress_log_desc[has_done]',
autoScroll: true,
listeners:{//监听此字段的render事件
render:function(he){
var data=Ext.getCmp('_mng_task_track_win_form_').getForm().result_data
if(data!=null&&data!=undefined){
he.setValue(data["progress_log_desc[has_done]"])
}
}
}
}
}, {
title : track_window.column.text_what_impedes,
height : 180,
layout:'fit',
items:{
xtype : 'htmleditor',
name : 'progress_log_desc[impedes]',
autoScroll: true,
listeners:{
render:function(he){
var data=Ext.getCmp('_mng_task_track_win_form_').getForm().result_data
if(data!=null&&data!=undefined){
he.setValue(data["progress_log_desc[impedes]"])
}
}
}
}
}, {
title : track_window.column.text_what_next,
height : 180,
layout:'fit',
items:{
xtype : 'htmleditor',
name : 'progress_log_desc[the_next]',
autoScroll: true,
listeners:{
render:function(he){
var data=Ext.getCmp('_mng_task_track_win_form_').getForm().result_data
if(data!=null&&data!=undefined){
he.setValue(data["progress_log_desc[the_next]"])
}
}
}
}
}, {
title : track_window.column.text_other_comments,
height : 180,
layout:'fit',
items:{
xtype : 'htmleditor',
name : 'progress_log_desc[other_comments]',
autoScroll: true,
listeners:{
render:function(he){
var data=Ext.getCmp('_mng_task_track_win_form_').getForm().result_data
if(data!=null&&data!=undefined){
he.setValue(data["progress_log_desc[other_comments]"])
}
}
}
}
}]
}

No responses yet

如何获取Ext.form.FormPanel的load和submit事件

Apr 15 2009 Published by Tony under Javascript

在使用ExtJs.form.FormPanel的过程中,有很多时候需要获得装载数据完成时的事件,那么一般这种事件怎么获得呢?请看如下示例:


Ext.getCmp('tabs').getForm().on("actioncomplete",
function(from,action){
if(action.type=="submit")
{
console.log(action.result)
}
})

其中Ext.getCmp('tabs')
是假设有一个id=‘tabs’的FormPanel。而action.type就是指事件(action)的类型。目前有两种分别为’submit’和’load’。

No responses yet

Ext.Window 问题总结

Apr 15 2009 Published by Tony under Javascript

Ext.Window 是Ext中最漂亮的widgets之一。但是在实际开发中问题多多。
关于隐藏:

  • 问题:作为一个重量级widgets,为了减少资源的消耗,每当关闭时,window默认为隐藏模式,可是每次你再打开这个window的时候,会发现window中的数据(我的习惯是在window中嵌套formPanel,我所指的数据是formPanel中的数据)可能并没有变,或者说更新。其中大部分原因,要么是formPanel没有load数据,要么是window初始化的时候把某个数据传给了某个监听器或者handler,而再次打开window的时候,数据并没有传过去。
  • 办法1:这种办法就是不用隐藏,每次都打开,在关闭window的监听器中,或者关闭window的时候distroy这个对象,记住在这之前一定要把这个window中引用到的其他对象也要distroy掉,之后在把它们的引用设为null。办法比较土,但是管事,好使。这样做一定记住设置closeAction:’close’
  • 办法2 不distroy任何对象,把一种办法中出现混淆的变量以参数的形式传给handler。在这里一定要关注的是嵌套在windows中的formpanel中的隐藏域,load数据的时候一定要保证所有的field都是load出来的。最后加一个mask,保证load的完整性。closeAction:’hide’。

One response so far

« Prev