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. html5版 音乐播放器

    html5版本音乐播放器,支持iOS设备,案例地址:http://www.xttblog.com/?p=1277 功能说明 支持iOS设备,但是iOS不支持自动下一曲,这是iOS本身限制,支持touc ...

  2. 如何使用 libqr 库生成二维码?

    使用 libqr 库只需 4 步即可生成二维码 1.初始化 QRCode 结构体 QRCode *qrInit(int version, int mode, int eclevel, int mask ...

  3. CodeForces-747E

    这几天好懒,昨天写的题,今天才来写博客.... 这题你不知道它究竟有多少层,但是知道字符串长度不超过10^6,那么它的总容量是被限定的,用一个二维动态数组就OK了.输入字符串后,可以把它按照逗号分割成 ...

  4. java网络编程(3)——UDP

    UDP在java中主要使用DatagramSocket来实现通讯,数据一般是通过DatagramPacket来封装: 发送方只需指定接受方的地址和端口,然后通过send()方法就可以把封装在Datag ...

  5. 在浏览器地址栏输入URL,按下回车后究竟发生了什么?

    1.DNS 在浏览器中输入URL后,首先要进行DNS解析,DNS解析的顺序为: 浏览器缓存 本地hosts文件 系统缓存 路由器缓存 DNS服务器迭代查询 2.发送请求 通过DNS得到目标的IP地址后 ...

  6. 从零开始学习前端JAVASCRIPT — 14、闭包与继承

    一.闭包 1 . 概念:闭包就是能够读取其他函数内部变量的函数.在JS中,只有函数内部的子函数才能读取局部变量,因此可以把闭包简单理解为”定义在一个函数内部的函数”. 2 . 闭包的特点 1)可以读取 ...

  7. Linux中select poll和epoll的区别

    在Linux Socket服务器短编程时,为了处理大量客户的连接请求,需要使用非阻塞I/O和复用,select.poll和epoll是Linux API提供的I/O复用方式,自从Linux 2.6中加 ...

  8. linux pxe网络装机无人值守

    项目分析远程装机的实现:配置DHCP+HTTP+TFTP提供通过vesamenu.c32模块实现图形PXE菜单为不同系统分别提供ks应答文件将第三方rpm包以yum源的方式提供:集中提供ntfs-3g ...

  9. 嵌入式Linux引导过程之1.4——Xloader的ddr_init

    这里我们来看XLOADER_ENTRY中调用的第二个标号ddr_init处的代码,这部分代码的作用是对外部内存SDRAM进行初始化,在我 spearplus开发板中,使用的是DDR SDRAM.在调用 ...

  10. Netty未来展望

    作为<Netty权威指南(第2版)>的结尾章节,和读者朋友们一起展望下Netty的未来. 1应用范围 随着大数据.互联网和云计算的发展,传统的垂直架构逐渐将被分布式.弹性伸缩的新架构替代. ...