FineUI控件集合
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控件集合的更多相关文章
- 控件包含代码块(即 <% ... %>),因此无法修改控件集合
错误: “/”应用程序中的服务器错误. 控件包含代码块(即 <% ... %>),因此无法修改控件集合. 说明: 执行当前 Web 请求期间,出现未经处理的异常.请检查堆栈跟踪信息,以了解 ...
- 如何优化 FineUI 控件库的性能,减少 80% 的数据上传量!
在开始正文之前,请帮忙为当前排名前 10 唯一的 .Net 开源软件 FineUI 投一票: 投票地址: https://code.csdn.net/2013OSSurvey/gitop/codevo ...
- selenium遍历控件集合
场景:需要重复增加地址栏信息,如果地址信息超过了5个就不开始增加 如图: 1.找到控件集合,在遍历每个子元素,在进行选择 1.先找到最外层的div的控件集合 2.外层的css定位为: int star ...
- asp.net 中的那些编译错误(1):控件包含代码块(即<% ... %>),因此无法修改控件集合
在编译页面的时候出现:控件包含代码块(即 <% ... %>),因此无法修改控件集合错误 一般原因是: 在<head runat="server">< ...
- Winform 后台将指定的控件集合添加到制定容器中
/// <summary> /// 把按钮按照行数分割排列 /// </summary> /// <param name="ControlArry"& ...
- FineUI控件之树的应用(二)
一.Tree控件应用 <f:PageManager ID="PageManager1" runat="server" /> <f:Tree I ...
- fullcalendar日历控件集合知识
1.基本的语法: 首先,fullcalendar和JQUERY一样,以面向对象的方式来组织代码.当然,这里的面向对象不过指能够把整个fullcalendar理解为一个类,这个类里包含有非常多的属性.方 ...
- WPF常用数据绑定控件集合
1.怎么用ListView控件把XML中的数据在界面上显示出来? <?xml version="1.0" encoding="utf-8" ?> & ...
- 使用<% =Type%>获取后台值时报错:控件包含代码块(即 <% ... %>),因此无法修改控件集合。
<% =Type%>不能放在runat="server"的标签中,删掉runat="server"之后dev的控件回调第一次发生时会刷新页面,有ru ...
随机推荐
- ASP.NET没有魔法——ASP.NET MVC 模型绑定解析(上篇)
前面文章介绍了ASP.NET MVC中的模型绑定和验证功能,本着ASP.NET MVC没有魔法的精神,本章内容将从代码的角度对ASP.NET MVC如何完成模型的绑定和验证进行分析,已了解其原理. 本 ...
- PAT乙级 1034
思路:是个水题,但是有坑.不能被题目忽悠了,题目保证正确的输出中没有超过整型范围的整数. 它只是保证结果不超出int,但是我们在运算过程中的乘法可能会超出int,直接把所有int改成long long ...
- CodeForces-749B
给定3个坐标,求可能构成平行四边形的第四个点,枚举两个点,根据这两个点的横纵坐标差,来得到第四个点的坐标,注意生成的坐标需要判重. AC代码: #include<cstdio> #incl ...
- H3C路由交换常用命令
1.查看Linux下查看端口状态 root@root:~# netstat -an|grep -E "6002|6003" 2.H3C交换机显示当前配置 [H3C]display ...
- jsp页面报错(一)
jsp页面报错 1.错误位置 <form action="../page/areaType.action" method="POST"> <j ...
- 错误代码: 1054 Unknown column 't.createUsrId' in 'group statement'
1.错误描述 1 queries executed, 0 success, 1 errors, 0 warnings 查询:select count(t.id),t.`createUserId` fr ...
- java 单例模式-饿懒汉模式
单例-饿汉模式 1.将构造方法私有化,不允许外部直接创建对象 private Singleton(){}2.自己在类的内部创建一个唯一实例 private static Singleton insta ...
- Hibernate【缓存】知识要点
对象状态 Hibernate中对象的状态: 临时/瞬时状态 持久化状态 游离状态 学习Hibernate的对象状态是为了更清晰地知道Hibernate的设计思想,以及是一级缓存的基础...当然啦,也就 ...
- ajax就收data的参数
一,变量 "data": ${cityData},//数据(必传) 二,json data:{"state":"Front"},
- 浅谈java编译机制和运行机制
源文件和字节码的组成方式 源文件: 拓展名后跟java的文件即java的源文件. Java 源码编译由以下三个过程组成: 1.分析和输入到符号表 2.注解处理 3.语义分析和生成class文件 流程图 ...