|
本帖最后由 世界没有真情 于 2013-10-1 17:57 编辑
- <P> /// <summary>
- /// 左侧导航js脚本
- /// </summary>
- /// <param name="treeid"></param>
- /// <returns></returns>
- private string GetScriptById(string treeid)
- {
- StringBuilder str = new StringBuilder();
- str.AppendLine("var " + treeid + " = Ext.getCmp("" + treeid + "");");
- str.AppendLine(treeid + ".on('click', function (node, event) {");
- str.AppendLine("if (node.isLeaf()) {");
- str.AppendLine("event.stopEvent();");
- str.AppendLine("var href = node.attributes.href;");
- str.AppendLine("window.location.href = '#' + href;");
- str.AppendLine("addExampleTab(node);");
- str.AppendLine("}");
- str.AppendLine("});");
- return str.ToString();
- }</P>
- <P>//后台动态调用</P>
- <P> /// <summary>
- /// 初始化菜单
- /// </summary>
- private void IniMenu()
- {
- accordionMenu.Panes.Clear();
- bool alreadyShow = false;
- List<Modelt_PageColumn> menuList = new BLL.BLLt_master().GetPages(Session[DString.MUSER_ID].ToInt());</P>
- <P> foreach (Modelt_PageColumn page in menuList.FindAll(delegate(Modelt_PageColumn model)
- {
- if (model.ViewMode.Equals(false))
- {
- return false;
- }
- return model.parentId.Equals(null);
- }))
- {
- AccordionPane ap = new AccordionPane();
- ap.Title = page.PageColumnName;
- ap.Layout = Layout.Fit;
- ap.ShowHeader = false;
- ap.IconUrl = page.icon;
- ap.ID = "AccordionPane" + page.PageColumnId;
- accordionMenu.Panes.Add(ap);</P>
- <P> Tree tree = new Tree();
- tree.ID = "tree" + page.PageColumnId;
- tree.ShowHeader = false;
- tree.ShowBorder = false;
- tree.AutoScroll = true;
- PageContext.RegisterStartupScript(GetScriptById("RegionPanel1_Region2_accordionMenu_" + ap.ID + "_" + tree.ID));
- CreatMenu(page.PageColumnId, menuList, tree, ap, ref alreadyShow);</P>
- <P> }
-
- }</P>
- <P>//default.js 中 addExampleTab 方法</P>
- <P>// 动态添加一个标签页
- function addExampleTab(node) {
- var href = node.attributes.href;</P>
- <P> // 动态创建按钮
- // var sourcecodeButton = new Ext.Button({
- // text: "源代码",
- // type: "button",
- // cls: "x-btn-text-icon",
- // icon: "./res.axd?icon=PageWhiteCode",
- // listeners: {
- // click: function (button, e) {
- // windowSourceCode.box_show('./source.aspx?files=' + href, '源代码');
- // e.stopEvent();
- // }
- // }
- // });</P>
- <P> var openNewWindowButton = new Ext.Button({
- text: '新标签页中打开',
- type: "button",
- cls: "x-btn-text-icon",
- icon: "./res.axd?icon=TabGo",
- listeners: {
- click: function (button, e) {
- window.open(href, "_blank");
- e.stopEvent();
- }
- }
- });</P>
- <P> var refreshButton = new Ext.Button({
- text: '刷新',
- type: "button",
- cls: "x-btn-text-icon",
- icon: "./res.axd?icon=Reload",
- listeners: {
- click: function (button, e) {
- // 注意:button.ownerCt 是工具栏,button.ownerCt.ownerCt 就是当前激活的标签页。
- Ext.DomQuery.selectNode('iframe', button.ownerCt.ownerCt.getEl().dom).contentWindow.location.replace(href);
- e.stopEvent();
- }
- }
- });</P>
- <P> // 动态添加一个带工具栏的标签页
- var tabId = 'dynamic_added_tab' + node.id.replace('__', '-');
- var currentTab = mainTabStrip.getTab(tabId);
- if (!currentTab) {
- mainTabStrip.addTab({
- 'id': tabId,
- 'url': href,
- 'title': node.text,
- 'closable': true,
- 'bodyStyle': 'padding:0px;',
- 'iconCls': 'icon_' + href.replace(/[^.]+\./, ''),
- 'tbar': new Ext.Toolbar({
- items: ['->', refreshButton, '-', openNewWindowButton]
- })
- });
- } else {
- mainTabStrip.setActiveTab(currentTab);
- }
- }</P>
- <P> mainTabStrip.on('tabchange', function (tabStrip, tab) {
- if (tab.url) {
- window.location.href = '#' + tab.url;
- } else {
- window.location.href = '#';
- }
- });</P>
- <P> </P>
- <P> </P>
复制代码 最后出错:addExampleTab is not defined
|
|