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. 项目中常用的19条MySQL优化

    声明一下:下面的优化方案都是基于 " Mysql-索引-BTree类型 " 的 一.EXPLAIN 做MySQL优化,我们要善用 EXPLAIN 查看SQL执行计划. 下面来个简单 ...

  2. 1×1卷积的用途(Network in Network)

    1×1卷积,又称为Network in Network 如果卷积的输出输入都只是一个平面,那么1x1卷积核并没有什么意义,它是完全不考虑像素与周边其他像素关系. 但卷积的输出输入是长方体,所以1x1卷 ...

  3. B. Pyramid of Glasses

    原题链接 B. Pyramid of Glasses Mary has just graduated from one well-known University and is now attendi ...

  4. mongodb Decimal Spring data mongodb Decimal128 SpringMvc 序列化字符串 json converter

    Mongodb 3.4 就开始支持Decimal 类型,解决double的精度问题,但是不太好用,MapReduce的时候Array.sum 也不能计算 Decimal.比较坑,但是聚合可以用 Spr ...

  5. 使用sed删除拼音的音调

    */ .hljs { display: block; overflow-x: auto; padding: 0.5em; color: #333; background: #f8f8f8; } .hl ...

  6. linux Cacti监控服务器搭建

    搭建Cacti监控服务器 部署安装环境(lamp) [root@zhuji1 ~]# yum -y install httpd [root@zhuji1 ~]# yum -y install php ...

  7. 10种软件开发中 over-engineering 的错误套路

    别把「不要过度使用 Generic」误解成「不用 Generic」,也别把「不要写一些不必要的 Wrapper」误解成「不写任何 Wrapper」.我只是在讲 over-engineering 这个事 ...

  8. eclipse生成【带有外部jar包】的java可执行jar包

    之前有写过一篇使用eclipse生成java可执行jar包,但是最近的一次使用中无论如何都不成功,当双击执行打成的jar时,弹出如下错误: could not find the main class: ...

  9. Linux中的DRM

    如果在搜索引擎离搜索 DRM 映入眼帘的尽是Digital Rights Managemen,也就是数字版权加密保护技术.这当然不是我们想要的解释.在类unix世界中还有一个DRM即The Direc ...

  10. php学习笔记之一维数组

    数组是指可以存放多个数据的数据类型. PHP中数组是一组关键字(key)和值(values)的集合,值可以是任何一种数据类型, 一维数组的创建方式: $arr=array(2,5,6); $arr=a ...