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 ...
随机推荐
- python爬虫提取冰与火之歌五季的种子
# -*- encoding:utf-8 -*- import requests import re import sys reload(sys) sys.setdefaultencoding(&qu ...
- hdu 2048 递推&&错排
直接贴出递推公式: cnt[n]=(i-1)*(cnt[n-1]+cnt[n-2]); 数组保存的是失败的种数 AC代码: #include<cstdio> const int maxn= ...
- Markdown语法你都会了吗?
关于Markdown,它可以说是程序员公认最好的文档语言了,没有之一!我相信经常写文章或者开发文档的大佬们都对其能生成简洁.大方.雅观的文档都深有体会,它的强大是毋庸置疑的.它编写的文档不但能生成ht ...
- Frequent Pattern (FP Growth算法)
FP树构造 FP Growth算法利用了巧妙的数据结构,大大降低了Aproir挖掘算法的代价,他不需要不断得生成候选项目队列和不断得扫描整个数据库进行比对.为了达 到这样的效果,它采用了一种简洁的数据 ...
- nginx笔记3-负载均衡算法
1.nginx测试:先从官网下载nginx 官网网址为:http://nginx.org/ 然后找到stable version的版本下载,因为这版本是最稳定的,不要去下载最新,因为不稳定,如下图: ...
- hive:排序分析函数
基本排序函数 语法: rank()over([partition by col1] order by col2) dense_rank()over([partition by col1] order ...
- linux虚拟化概述
虚拟化硬件虚拟化:一台物理机虚拟出多台逻辑上的计算机cpu,内存可分配给多个虚拟机软件虚拟化:一个LAMP平台支撑多个网站桌面虚拟化...... 虚拟机:通过软件平台模拟出的计算机对最终用户来说,感受 ...
- Linux SendMail发送邮件失败诊断案例(四)
最近又碰到一起Linux下SendMail发送邮件失败的案例,邮件发送后,邮箱收不到具体邮件, 查看日志/var/log/maillog 发现有"DSN: User unknown" ...
- 一文解决python模块导入
python 模块导入 原理 查找是按照 sys.path 中的路径挨个扫描.若都不存在则提示error. sys.path路径第一个是当前运行脚本所在的目录,其后是PYTHONPATH(一般若步专门 ...
- dojo实现省份地市级联报错(一)