首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Ajax >

ext tabpanel有关问题 高分回报

2012-02-10 
ext tabpanel问题 高分回报 - Web 开发 / Ajaxmain.jsJScript codevar addWinfunction addClick(){if(!add

ext tabpanel问题 高分回报 - Web 开发 / Ajax
main.js

JScript code
var addWinfunction addClick(){    if(!addWin)    {        addWin=new Ext.Window({            title:'tabPanel',            width:500,            height:400,            closable:true,            closeAction:'hide',            /*listeners:{                'hide':function(){alert("hide");}      //隐藏windows时触发该事件            },*/            items:[tabPanle],            buttons:[{                text:'关闭',                handler:function(){addWin.hide()}            }]        });    }    addWin.show(this);}var tabPanle=new Ext.TabPanel({    activeTab:0,    width:480,    height:330,    layoutOnTabChange:true,    items:[{        title:'tabPanel-Three',        autoLoad:{            url:'panel_One.jsp',            scripts:true        }    },{        title:'tabPanel-Three',        autoLoad:{            url:'panel_Two.jsp'        }    }]});

出来现世一个tabpanel面板,上面有两个选项卡,
第一个选项卡的autoLoad到panel_One.jsp页面 就单纯现世一个panel面板
代码:
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page isELIgnored="true"%> 

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <base href="<%=basePath%>">
   
  <title>My JSP 'panel_One.jsp' starting page</title>
   
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">  
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<link rel="stylesheet" href="<%=basePath%>extjs/resources/css/ext-all.css" type="text/css"></link>
  <script type="text/javascript" src="<%=basePath%>extjs/adapter/ext/ext-base.js"></script>  
  <script type="text/javascript" src="<%=basePath%>extjs/ext-all.js"></script>  

  </head>
  <script type="text/javascript">
  Ext.onReady(function(){
  var one_Panel=new Ext.Panel({
  renderTo:'rightGridDiv_one',
  title:'onePanel',
  html:'onePanel的内容'
  });
  one_Panel.show();
  });
  </script>
  <body>
  panel_One<br>
  <div id="rightGridDiv_one"></div>
  </body>
</html>


第二个选项卡的autoLoad到panel_Two.jsp 就显示一句话:panel_Two 
代码
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page isELIgnored="true"%> 

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <base href="<%=basePath%>">
   
  <title>My JSP 'panel_Two.jsp' starting page</title>


   
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">  
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<link rel="stylesheet" href="<%=basePath%>extjs/resources/css/ext-all.css" type="text/css"></link>
  <script type="text/javascript" src="<%=basePath%>extjs/adapter/ext/ext-base.js"></script>  
  <script type="text/javascript" src="<%=basePath%>extjs/ext-all.js"></script>  

  </head>
  
  <body>
  panel_Two <br>
  </body>
</html>

tabpanel默认显示第一个选项卡,
内容能正确显示出来
但是单击第二个选项卡时就报错
内容也不能显示


高手帮忙。。。。。。。。。。。。。。。。

需求效果:
我要做的效果实际上就是通过tabpanel的选项卡显示不同的内容,内容都是另外的一个页面上的内容,
其他页面上可以有ext控件代码,也可以没有ext控件代码,

用ifarme实现也可以



谁要是有例子可以给发下啊

一定非常感谢

高分回报



[解决办法]
贴个 例子

Ext.onReady(function() {

// The only requirement for this to work is that you must have a hidden field and
// an iframe available in the page with ids corresponding to Ext.History.fieldId
// and Ext.History.iframeId. See history.html for an example.
Ext.History.init();

// Needed if you want to handle history for multiple components in the same page.
// Should be something that won't be in component ids.
var tokenDelimiter = ':';

var tp = new Ext.TabPanel({
renderTo: Ext.getBody(),
id: 'main-tabs',
height: 300,
width: 600,
activeTab: 0,

items: [{
xtype: 'tabpanel',
title: 'Tab 1',
id: 'tab1',
activeTab: 0,
tabPosition: 'bottom',

items: [{
title: 'Sub-tab 1',
id: 'subtab1'
},{
title: 'Sub-tab 2',
id: 'subtab2'
},{
title: 'Sub-tab 3',
id: 'subtab3'
}],

listeners: {
'tabchange': function(tabPanel, tab){
Ext.History.add(tabPanel.id + tokenDelimiter + tab.id);
}
}
},{
title: 'Tab 2',
id: 'tab2'
},{
title: 'Tab 3',
id: 'tab3'
},{
title: 'Tab 4',
id: 'tab4'
},{
title: 'Tab 5',
id: 'tab5'
}],

listeners: {
'tabchange': function(tabPanel, tab){
// Ignore tab1 since it is a separate tab panel and we're managing history for it also.
// We'll use its handler instead in that case so we don't get duplicate nav events for sub tabs.
if(tab.id != 'tab1'){
Ext.History.add(tabPanel.id + tokenDelimiter + tab.id);
}
}
}
});

// Handle this change event in order to restore the UI to the appropriate history state
Ext.History.on('change', function(token){
if(token){
var parts = token.split(tokenDelimiter);
var tabPanel = Ext.getCmp(parts[0]);
var tabId = parts[1];


tabPanel.show();
tabPanel.setActiveTab(tabId);
}else{
// This is the initial default state. Necessary if you navigate starting from the
// page without any existing history token params and go back to the start state.
tp.setActiveTab(0);
tp.getItem(0).setActiveTab(0);
}
});

});
[解决办法]

没写过你那样的
嘿嘿
 我也学习下..
 我一般要实现你所说的效果都是

JScript code
        var testTab = new Ext.TabPanel({        id : 'testTab',        layoutOnTabChange : true,        frame : true,        enableTabScroll : true    });    testTab.add({        title : '测试表1',        id : 'tab1',        closable : false,        border : true,        layout : 'column',        height : 280,        items : [{}]    })            testTab.add({        title : '测试表2',        id : 'tab2',        closable : false,        border : true,        layout : 'column',        height : 280,        items : [{}]    })
[解决办法]
JScript code
 var tabPanle=new Ext.TabPanel({    activeTab:0,    width:480,    height:330,    layoutOnTabChange:true,    items:[{          xtype:'panel',        title:'tabPanel-Three',               html:'<iframe src=login.HTML width=100% height=100%></iframe>'    },{        xtype:'panel',        title:'tabPanel-Three',        html:'<iframe src=test.HTML width=100% height=100%></iframe>'    }]});
[解决办法]
用panel直接加载
JScript code
 var tabPanle=new Ext.TabPanel({             activeTab:0,            width:480,            height:330,            layoutOnTabChange:true,            items:[{                title : "第一页",                closable : false,                autoLoad : {                    url : 'page/page1.jsp',                    scope : this,                    scripts : true                }},{                title : "第二页",                closable : false,                autoLoad : {                    url : 'page/page2.jsp',                    scope : this,                    scripts : true                }}]        });
[解决办法]
如果你是用ext的autoLoad加载 那么载入的页面中不可以再引用ext包, 如果是利用iframe加载,新页面中必须重新引入ext包

热点排行