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

 using System;
using System.Collections.Generic;
using System.Text;
using System.Collections.ObjectModel;
using System.Web.UI;
using System.Collections; namespace FineUI
{
/// <summary>
/// 控件集合,继承自Collection<T>
/// </summary>
public class BaseCollection<T> : Collection<T> where T : ControlBase
{
private ControlBase _parent;
private string _groupName; /// <summary>
/// 构造函数
/// </summary>
/// <param name="parentControl">父控件实例</param>
public BaseCollection(ControlBase parentControl)
{
_parent = parentControl;
_groupName = Guid.NewGuid().ToString();
} /// <summary>
/// 向集合中插入一个元素
/// </summary>
/// <param name="index"></param>
/// <param name="item"></param>
protected override void InsertItem(int index, T item)
{
item.CollectionGroupName = _groupName;
item.RenderWrapperNode = false; int startIndex = GetStartIndex();
_parent.Controls.AddAt(startIndex + index, item); base.InsertItem(index, item);
} /// <summary>
/// 删除集合中的一个元素
/// </summary>
/// <param name="index"></param>
protected override void RemoveItem(int index)
{
int startIndex = GetStartIndex();
_parent.Controls.RemoveAt(startIndex + index); base.RemoveItem(index);
} /// <summary>
/// 清空集合
/// </summary>
protected override void ClearItems()
{
int startIndex = GetStartIndex();
// We should only remove this collection related controls
// Note we must loop from the last element(Count-1) to the first one(0)
for (int i = startIndex + Count - 1; i >= startIndex; i--)
{
_parent.Controls.RemoveAt(i);
} base.ClearItems();
} /// <summary>
/// 获取类型 T 在父控件子集中的开始位置
/// </summary>
/// <returns></returns>
private int GetStartIndex()
{
int startIndex = 0; foreach (Control control in _parent.Controls)
{
if (control is ControlBase && (control as ControlBase).CollectionGroupName == _groupName)
{
break;
}
startIndex++;
} return startIndex;
} }
}
 function onReady() {
var btnExpandAll = Ext.getCmp(IDS.btnExpandAll);
var btnCollapseAll = Ext.getCmp(IDS.btnCollapseAll);
var mainMenu = Ext.getCmp(IDS.mainMenu);
var mainTabStrip = Ext.getCmp(IDS.mainTabStrip);
var windowSourceCode = Ext.getCmp(IDS.windowSourceCode); function getExpandedPanel() {
var panel = null;
mainMenu.items.each(function (item) {
if (!item.collapsed) {
panel = item;
}
});
return panel;
} // 点击全部展开按钮
btnExpandAll.on('click', function () {
if (IDS.menuType == "menu") {
mainMenu.expandAll();
} else {
var expandedPanel = getExpandedPanel();
if (expandedPanel) {
expandedPanel.items.itemAt(0).expandAll();
}
}
}); // 点击全部折叠按钮
btnCollapseAll.on('click', function () {
if (IDS.menuType == "menu") {
mainMenu.collapseAll();
} else {
var expandedPanel = getExpandedPanel();
if (expandedPanel) {
expandedPanel.items.itemAt(0).collapseAll();
}
}
}); function createToolbar() { // 由工具栏上按钮获得当前标签页中的iframe节点
function getCurrentIframeNode(button) {
// 注意:button.ownerCt 是工具栏,button.ownerCt.ownerCt 就是当前激活的标签页。
return Ext.DomQuery.selectNode('iframe', button.ownerCt.ownerCt.el.dom);
} // 动态创建按钮
var sourcecodeButton = new Ext.Button({
text: "源代码",
type: "button",
cls: "x-btn-text-icon",
icon: "./icon/page_white_code.png",
listeners: {
click: function (button, e) {
windowSourceCode.x_show('./common/source.aspx?files=' + getCurrentIframeNode(button).attributes['src'].value, '源代码');
e.stopEvent();
}
}
}); var openNewWindowButton = new Ext.Button({
text: '新标签页中打开',
type: "button",
cls: "x-btn-text-icon",
icon: "./icon/tab_go.png",
listeners: {
click: function (button, e) {
window.open(getCurrentIframeNode(button).src, "_blank");
e.stopEvent();
}
}
}); var refreshButton = new Ext.Button({
text: '刷新',
type: "button",
cls: "x-btn-text-icon",
icon: "./icon/reload.png",
listeners: {
click: function (button, e) {
getCurrentIframeNode(button).contentWindow.location.reload(); //.replace(href);
e.stopEvent();
}
}
}); return new Ext.Toolbar({
items: ['->', sourcecodeButton, '-', refreshButton, '-', openNewWindowButton]
});
} // 初始化主框架中的树(或者Accordion+Tree)和选项卡互动,以及地址栏的更新
// 1. treeMenu, 主框架中的树控件实例,或者内嵌树控件的手风琴控件实例
// 2. mainTabStrip, 主框架中的选项卡控件实例
// 3. tbarCallback, 在每个选项卡上创建工具栏的回调函数,如果不需要选项卡工具栏,可以设置此值为null
// 4. updateLocationHash, 切换选项卡时是否在top.location.hash记录当前页面的地址
X.util.initTreeTabStrip(mainMenu, mainTabStrip, createToolbar, true); // 公开添加示例标签页的方法
window.addExampleTab = function (id, url, text, icon) {
X.util.addMainTab(mainTabStrip, id, url, text, icon);
}; window.removeActiveTab = function () {
var activeTab = mainTabStrip.getActiveTab();
mainTabStrip.removeTab(activeTab.id);
}; }

FineUI控件集合的更多相关文章

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

    错误: “/”应用程序中的服务器错误. 控件包含代码块(即 <% ... %>),因此无法修改控件集合. 说明: 执行当前 Web 请求期间,出现未经处理的异常.请检查堆栈跟踪信息,以了解 ...

  2. 如何优化 FineUI 控件库的性能,减少 80% 的数据上传量!

    在开始正文之前,请帮忙为当前排名前 10 唯一的 .Net 开源软件 FineUI 投一票: 投票地址: https://code.csdn.net/2013OSSurvey/gitop/codevo ...

  3. selenium遍历控件集合

    场景:需要重复增加地址栏信息,如果地址信息超过了5个就不开始增加 如图: 1.找到控件集合,在遍历每个子元素,在进行选择 1.先找到最外层的div的控件集合 2.外层的css定位为: int star ...

  4. asp.net 中的那些编译错误(1):控件包含代码块(即<% ... %>),因此无法修改控件集合

    在编译页面的时候出现:控件包含代码块(即 <% ... %>),因此无法修改控件集合错误 一般原因是: 在<head runat="server">< ...

  5. Winform 后台将指定的控件集合添加到制定容器中

    /// <summary> /// 把按钮按照行数分割排列 /// </summary> /// <param name="ControlArry"& ...

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

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

  7. fullcalendar日历控件集合知识

    1.基本的语法: 首先,fullcalendar和JQUERY一样,以面向对象的方式来组织代码.当然,这里的面向对象不过指能够把整个fullcalendar理解为一个类,这个类里包含有非常多的属性.方 ...

  8. WPF常用数据绑定控件集合

    1.怎么用ListView控件把XML中的数据在界面上显示出来? <?xml version="1.0" encoding="utf-8" ?> & ...

  9. 使用<% =Type%>获取后台值时报错:控件包含代码块(即 <% ... %>),因此无法修改控件集合。

    <% =Type%>不能放在runat="server"的标签中,删掉runat="server"之后dev的控件回调第一次发生时会刷新页面,有ru ...

随机推荐

  1. MySQL的常见存储引擎介绍与参数设置调优

    MySQL常用存储引擎之MyISAM 特性: 1.并发性与锁级别 2.表损坏修复 check table tablename repair table tablename 3.MyISAM表支持的索引 ...

  2. C语言老司机学Python (五)

    今天看的是标准库概览. 操作系统接口: 用os模块实现. 针对文件和目录管理,还有个shutil模块可以用. 例句: import os os.getcwd() # 返回当前的工作目录 os.chdi ...

  3. web前端研发工程师编程能力成长之路

    [背景] 如果你是刚进入WEB前端研发领域,想试试这潭水有多深,看这篇文章吧:如果你是做了两三年WEB产品前端研发,迷茫找不着提高之路,看这篇文章吧:如果你是四五年的前端开发高手,没有难题能难得住你的 ...

  4. Git & github 使用指南

    Git的安装: 1.下载 Git for windows下载网址:https://git-for-windows.github.io/ 2.安装 选择安装路径: 选择组件:默认  是否修改环境变量 : ...

  5. AVS、MPEG-2、H264标准文档

    联合信源对AVS解码源码和相应的AVS码流.AVS码流太大,可以从http://cosoft.org.cn/projects/avsdec下载.解压avsdec_source.zip后,用VC6编译a ...

  6. ADS1.2中RO base与RW base

    ARM映像文件 ARM中的各种源文件(包括汇编文件,C语言程序及C++程序等)经过ARM编译器编译后生成ELF(Executable and linking format)格式的目标文件.这些目标文件 ...

  7. vxWorks6.6 N270 D525 cpu的bsp配置总结

    对硬盘的操作 使用SATA硬盘,分区,引导区(VxC:)必须格式化为FAT(FAT16)格式,所以该分区大小有限制,不能超过4G(4G大小带测试),设置C:为"活动的": 主机上安 ...

  8. org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException

    1.错误描述 usage: java org.apache.catalina.startup.Catalina [ -config {pathname} ] [ -nonaming ] { -help ...

  9. 解决DOS批处理中一个困扰我几十个月的编码问题

    DOS批处理中的编码很有意思.&是命令连接符,先执行&左边的命令,再执行&右边的命令.|是管道操作,把左边的输出当作右边的输入.此外还有&&和||,当要表示这些 ...

  10. SQLiteOpenHelper与SQLiteDatabase的使用

    1. 数据类型 与其它数据库不同,SQLite的数据类型很简单,只有NULL(空类型).INTEGER(整型).REAL(浮点型).TEXT(字符串型).BLOB(二进制型). SQLite为动态数据 ...