FineUI(开源版)基于 ExtJS 的开源 ASP.NET 控件库。

1 using System;2 using System.Collections.Generic;3 using System.Text;4 using System.Collections.ObjectModel;5 using System.Web.UI;6 using System.Collections;7
8 namespace FineUI9 {10     /// <summary>
11     /// 控件集合,继承自Collection<T>
12     /// </summary>
13     public class BaseCollection<T> : Collection<T>where T : ControlBase14 {15 private ControlBase _parent;16 private string _groupName;17
18         /// <summary>
19         /// 构造函数
20         /// </summary>
21         /// <param name="parentControl">父控件实例</param>
22 public BaseCollection(ControlBase parentControl)23 {24             _parent =parentControl;25             _groupName =Guid.NewGuid().ToString();26 }27
28         /// <summary>
29         /// 向集合中插入一个元素
30         /// </summary>
31         /// <param name="index"></param>
32         /// <param name="item"></param>
33         protected override void InsertItem(intindex, T item)34 {35             item.CollectionGroupName =_groupName;36             item.RenderWrapperNode = false;37
38             int startIndex =GetStartIndex();39             _parent.Controls.AddAt(startIndex +index, item);40
41 base.InsertItem(index, item);42 }43
44         /// <summary>
45         /// 删除集合中的一个元素
46         /// </summary>
47         /// <param name="index"></param>
48         protected override void RemoveItem(intindex)49 {50             int startIndex =GetStartIndex();51             _parent.Controls.RemoveAt(startIndex +index);52
53 base.RemoveItem(index);54 }55
56         /// <summary>
57         /// 清空集合
58         /// </summary>
59         protected override voidClearItems()60 {61             int startIndex =GetStartIndex();62             //We should only remove this collection related controls
63             //Note we must loop from the last element(Count-1) to the first one(0)
64             for (int i = startIndex + Count - 1; i >= startIndex; i--)65 {66 _parent.Controls.RemoveAt(i);67 }68
69 base.ClearItems();70 }71
72
73         /// <summary>
74         /// 获取类型 T 在父控件子集中的开始位置
75         /// </summary>
76         /// <returns></returns>
77         private intGetStartIndex()78 {79             int startIndex = 0;80
81             foreach (Control control in_parent.Controls)82 {83                 if (control is ControlBase && (control as ControlBase).CollectionGroupName ==_groupName)84 {85                     break;86 }87                 startIndex++;88 }89
90             returnstartIndex;91 }92
93 }94 }

1 functiononReady() {2     var btnExpandAll =Ext.getCmp(IDS.btnExpandAll);3     var btnCollapseAll =Ext.getCmp(IDS.btnCollapseAll);4     var mainMenu =Ext.getCmp(IDS.mainMenu);5     var mainTabStrip =Ext.getCmp(IDS.mainTabStrip);6     var windowSourceCode =Ext.getCmp(IDS.windowSourceCode);7
8     functiongetExpandedPanel() {9         var panel = null;10         mainMenu.items.each(function(item) {11             if (!item.collapsed) {12                 panel =item;13 }14 });15         returnpanel;16 }17
18     //点击全部展开按钮
19     btnExpandAll.on('click', function() {20         if (IDS.menuType == "menu") {21 mainMenu.expandAll();22         } else{23             var expandedPanel =getExpandedPanel();24             if(expandedPanel) {25                 expandedPanel.items.itemAt(0).expandAll();26 }27 }28 });29
30     //点击全部折叠按钮
31     btnCollapseAll.on('click', function() {32         if (IDS.menuType == "menu") {33 mainMenu.collapseAll();34         } else{35             var expandedPanel =getExpandedPanel();36             if(expandedPanel) {37                 expandedPanel.items.itemAt(0).collapseAll();38 }39 }40 });41
42     functioncreateToolbar() {43
44         //由工具栏上按钮获得当前标签页中的iframe节点
45         functiongetCurrentIframeNode(button) {46             //注意:button.ownerCt 是工具栏,button.ownerCt.ownerCt 就是当前激活的标签页。
47             return Ext.DomQuery.selectNode('iframe', button.ownerCt.ownerCt.el.dom);48 }49
50         //动态创建按钮
51         var sourcecodeButton = newExt.Button({52             text: "源代码",53             type: "button",54             cls: "x-btn-text-icon",55             icon: "./icon/page_white_code.png",56 listeners: {57                 click: function(button, e) {58                     windowSourceCode.x_show('./common/source.aspx?files=' + getCurrentIframeNode(button).attributes['src'].value, '源代码');59 e.stopEvent();60 }61 }62 });63
64         var openNewWindowButton = newExt.Button({65             text: '新标签页中打开',66             type: "button",67             cls: "x-btn-text-icon",68             icon: "./icon/tab_go.png",69 listeners: {70                 click: function(button, e) {71                     window.open(getCurrentIframeNode(button).src, "_blank");72 e.stopEvent();73 }74 }75 });76
77         var refreshButton = newExt.Button({78             text: '刷新',79             type: "button",80             cls: "x-btn-text-icon",81             icon: "./icon/reload.png",82 listeners: {83                 click: function(button, e) {84                     getCurrentIframeNode(button).contentWindow.location.reload(); //.replace(href);
85 e.stopEvent();86 }87 }88 });89
90         return newExt.Toolbar({91             items: ['->', sourcecodeButton, '-', refreshButton, '-', openNewWindowButton]92 });93 }94
95
96     //初始化主框架中的树(或者Accordion+Tree)和选项卡互动,以及地址栏的更新
97     //1. treeMenu, 主框架中的树控件实例,或者内嵌树控件的手风琴控件实例
98     //2. mainTabStrip, 主框架中的选项卡控件实例
99     //3. tbarCallback, 在每个选项卡上创建工具栏的回调函数,如果不需要选项卡工具栏,可以设置此值为null
100     //4. updateLocationHash, 切换选项卡时是否在top.location.hash记录当前页面的地址
101     X.util.initTreeTabStrip(mainMenu, mainTabStrip, createToolbar, true);102
103
104     //公开添加示例标签页的方法
105     window.addExampleTab = function(id, url, text, icon) {106 X.util.addMainTab(mainTabStrip, id, url, text, icon);107 };108
109     window.removeActiveTab = function() {110         var activeTab =mainTabStrip.getActiveTab();111 mainTabStrip.removeTab(activeTab.id);112 };113
114 }

View Code

转载于:https://www.cnblogs.com/cykj/p/FineUI-control-collection.html

FineUI控件集合相关推荐

  1. 控件包含代码块,因此无法修改控件集合

    文章转载至:  http://www.olnote.com/itlife/note/100000003.aspx 控件包含代码块(即<% ... %>),因此无法修改控件集合. 说明: 执 ...

  2. 控件包含代码块(即 % ... %),因此无法修改控件集合。

    第一种: 在使用主题的时候出现 控件包含代码块(即 <% ... %>),因此无法修改控件集合错误,原来错误的原因是: 控件包含代码块(即 <% ... %>),因此无法修改控 ...

  3. 控件包含代码块(即% ... %),因此无法修改控件集合解决

    控件包含代码块(即<% ... %>),因此无法修改控件集合 除了其他人分析的原因之外,还有我遇到的: 有人把Repeater里数据绑定写成<%=XXX%>,改了之后就没有那个 ...

  4. Android用户界面开发:控件集合

    一个Demo搞定30个控件 转载链接:http://www.apkbus.com/forum.php?mod=viewthread&tid=43667 源码下载链接:http://downlo ...

  5. 获取窗口上指定控件集合 2012-08-22 16:14 498人阅读 评论(0) 收藏...

    假如想获取一个Grid(名称为grid1)上所有的Button按钮,则代码如下: List<Button> collection = GetChildObjects<Button&g ...

  6. FineUI控件之树的应用(二)

    一.Tree控件应用 <f:PageManager ID="PageManager1" runat="server" /><f:Tree ID ...

  7. JS日历控件集合----附效果图、源代码

    在进行开发的过程中,经常需要输入时间,特别是在进行查询.统计的时候,时间限定更为重要. 尽管ASP.NET也集成了日历控件,但是其集成的代码量很大,你可以做一个测试,当你在页面使用一个日历控件时,在发 ...

  8. 「UG/NX」BlockUI 控件集合

    目录 说明 BlockUI 介绍 编辑界面进入步骤 BlockUI 控件 基本 (Basic) 数字 (Numbers) 布局 (Layout) 选择 (Selection) 特殊 (Special) ...

  9. ASP.NET控件集合

    文章目录 前言 一.控件分类 1.HTML控件 2.HTML服务器控件 3.ASP.NET服务器控件 4.用户控件和自定义控件 二.HTML控件和ASP.NET服务器控件 1.HTML控件 2.ASP ...

最新文章

  1. Yii2.0 模态弹出框+ajax提交表单
  2. 日本語のマナーを学びましょう
  3. ai作文批改_全球第一份机器人批改的作文 阿里AI批改中文试卷
  4. 深入Atlas系列:综合示例(1) - 调用服务器端方法时直接获得客户端具体类型...
  5. ubuntu三种添加环境变量的方法
  6. 《基于Mozilla的扩展开发》系列文章
  7. 赶在世界末日前完成的2012年全年总结
  8. 计算机考试祝福,考试前说的祝福语汇编35句 参加考试前的祝福语
  9. html 模拟鼠标移动,如何在网页端用js模拟鼠标移动点击等操作
  10. Spring colud gateway 源码小计
  11. #344 – 通过CanExecute控制按钮是可用(The CommandBinding CanExecute Determines Whether a Button is Enabled)
  12. 任天堂游戏 html5,任天堂Switch游戏销量排行Top40,赶快收藏跟着买就对啦!
  13. 强化学习之Grid World的时序差分算法解析【MiniWorld】SYSU_2023SpringRL
  14. 112、Flutter实现图片放大缩小的动画小
  15. 树莓派cups搭建无线打印机(HP Laserjet 1020)
  16. 基于python的批量网页爬虫
  17. VB里的 dim是什么意思?
  18. Java项目:医院管理系统(java+SpringBoot+Layui+Freemaker+maven+mysql)
  19. 倍福--绝对编码器位置保存
  20. (二)Qt多线程实现海康工业相机图像实时采集

热门文章

  1. sql优化的方法及思路_微生物发酵 技术优化思路 与方法
  2. ajax里拼接标签属性规则,vue 标签属性数据绑定和拼接的实现方法
  3. centos 一键安装ftp 配置_CentOS快速搭建FTP(初级-四步)
  4. linux odbc 数据源测试,linux操作系统配置ODBC数据源
  5. hadoop job 未跑满资源_mapreduce任务占满整个集群资源
  6. python3编码命名规范_Python代码规范和命名规范
  7. 单机多节点有意义吗_十行代码让你的单机“影分身”,分布式训练速度快到飞起...
  8. 全球及中国养老护理行业十四五趋势前景与投资动向建议报告2022版
  9. python 查看帮助
  10. VB.NET程序如何巧妙释放内存