[Ext.Net]TreePanel+gridPanel实例
@小花要完整例子,尝试一下图文并茂,力求完整。
前台代码
- <ext:ResourceManager ID="ResourceManager1" DirectMethodNamespace="RM" runat="server" />
- <ext:Store ID="StoreDeptDetailList" OnBeforeStoreChanged="StoreChanged" runat="server">
- <Reader>
- <ext:JsonReader IDProperty="ID">
- <Fields>
- <ext:RecordField Name="ID" />
- <ext:RecordField Name="wzdm" />
- ... ....
- <ext:RecordField Name="bz" />
- </Fields>
- </ext:JsonReader>
- </Reader>
- </ext:Store>
- <ext:Viewport ID="Viewport1" runat="server" Layout="border">
- <Items>
- <ext:Panel ID="Panel1" runat="server" Region="West" Split="true" Width="225" Border="false"
- AutoScroll="true">
- <Content>
- <ext:TreePanel ID="treePanel" runat="server" Border="false">
- <Root>
- </Root>
- <Listeners>
- <Click Handler="e.stopEvent();RM.NodeClick(node.id);" />
- </Listeners>
- </ext:TreePanel>
- </Content>
- </ext:Panel>
- <ext:Panel ID="PanelCenter" runat="server" Region="Center" Layout="Fit" Cls="ViewPortRight"
- ButtonAlign="Right" Width="270" Header="false" Title="物资明细" Icon="TableGear"
- Border="false">
- <Items>
- <ext:GridPanel ID="gpFuncsList" runat="server" StripeRows="true" ClicksToEdit="0"
- Header="false" Height="600" StoreID="StoreDeptDetailList" Border="true" TrackMouseOver="true">
- <TopBar>
- <ext:Toolbar ID="Toolbar2" runat="server" AutoWidth="true">
- <Items>
- <ext:Label runat="server" ID="lblTitle">
- </ext:Label>
- <ext:ToolbarFill ID="ToolbarFill1" runat="server" />
- <ext:Button ID="btnAdd" runat="server" Text="新增" Icon="Add">
- <Listeners>
- <Click Handler="#{gpFuncsList}.insertRecord();" />
- </Listeners>
- </ext:Button>
- <ext:Button ID="btnDelete" runat="server" Text="删除" Icon="Delete">
- <Listeners>
- <Click Handler="#{gpFuncsList}.deleteSelected();" />
- </Listeners>
- </ext:Button>
- <ext:Button ID="btnSave" runat="server" Text="保存" Icon="Disk">
- <Listeners>
- <Click Handler="#{gpFuncsList}.save();" />
- </Listeners>
- </ext:Button>
- </Items>
- </ext:Toolbar>
- </TopBar>
- <ColumnModel ID="ColumnModel1" runat="server">
- <Columns>
- <ext:Column ColumnID="wzmc" DataIndex="wzmc" Header="物资名称" Align="Center" Sortable="false">
- <Editor>
- <ext:TextField ID="TextField1" runat="server" />
- </Editor>
- </ext:Column>
- <ext:Column ColumnID="ggxh" DataIndex="ggxh" Header="规格型号" Align="Center" Sortable="false">
- <Editor>
- <ext:TextField ID="TextField2" runat="server" />
- </Editor>
- </ext:Column>
- <ext:Column ColumnID="bcdd" DataIndex="bcdd" Header="保存地点" Align="Center" Sortable="false">
- <Editor>
- <ext:TextField ID="TextField3" runat="server" />
- </Editor>
- </ext:Column>
- <ext:Column ColumnID="sccj" DataIndex="sccj" Header="生产厂家" Align="Center" Sortable="false">
- <Editor>
- <ext:TextField ID="TextField4" runat="server" />
- </Editor>
- </ext:Column>
- <ext:Column ColumnID="jxs" DataIndex="jxs" Header="经销商" Align="Center" Sortable="false">
- <Editor>
- <ext:TextField ID="TextField5" runat="server" />
- </Editor>
- </ext:Column>
- <ext:Column ColumnID="zzs" DataIndex="zzs" Header="制造商" Align="Center" Sortable="false">
- <Editor>
- <ext:TextField ID="TextField6" runat="server" />
- </Editor>
- </ext:Column>
- <ext:Column ColumnID="isny" DataIndex="isny" Header="是否为耐用品" Align="Center" Sortable="false">
- <Editor>
- <ext:ComboBox ID="TextField7" runat="server">
- <Items>
- <ext:ListItem Text="是" Value="是" />
- <ext:ListItem Text="否" Value="否" />
- </Items>
- </ext:ComboBox>
- </Editor>
- </ext:Column>
- <ext:Column ColumnID="jldw" DataIndex="jldw" Header="计量单位" Align="Center" Sortable="false">
- <Editor>
- <ext:ComboBox ID="ComboBox4" runat="server">
- <Items>
- <ext:ListItem Text="方" Value="方" />
- <ext:ListItem Text="公斤" Value="公斤" />
- <ext:ListItem Text="发" Value="发" />
- <ext:ListItem Text="根" Value="根" />
- <ext:ListItem Text="台" Value="台" />
- <ext:ListItem Text="灯" Value="灯" />
- <ext:ListItem Text="吨" Value="顿" />
- <ext:ListItem Text="米" Value="米" />
- <ext:ListItem Text="鞋" Value="鞋" />
- <ext:ListItem Text="套" Value="套" />
- <ext:ListItem Text="块" Value="块" />
- <ext:ListItem Text="辆" Value="辆" />
- <ext:ListItem Text="个" Value="个" />
- <ext:ListItem Text="把" Value="把" />
- </Items>
- </ext:ComboBox>
- </Editor>
- </ext:Column>
- <ext:Column ColumnID="cph" DataIndex="cph" Header="车牌号" Align="Center" Sortable="false">
- <Editor>
- <ext:TextField ID="TextField12" runat="server" />
- </Editor>
- </ext:Column>
- <ext:Column ColumnID="djgl" DataIndex="djgl" Header="电机功率" Sortable="false">
- <Editor>
- <ext:TextField ID="TextField13" runat="server" />
- </Editor>
- </ext:Column>
- <ext:Column ColumnID="zjs" DataIndex="jzs" Header="间(座)数" Align="Center" Sortable="false">
- <Editor>
- <ext:NumberField ID="TextField14" runat="server" />
- </Editor>
- </ext:Column>
- <ext:Column ColumnID="nx" DataIndex="nx" Header="使用年限" Align="Center" Sortable="false">
- <Editor>
- <ext:SpinnerField ID="SpinnerField2" runat="server" MinValue="1" MaxValue="100" AllowDecimals="true"
- DecimalPrecision="1" Accelerate="true" />
- </Editor>
- </ext:Column>
- <ext:Column ColumnID="scrq" DataIndex="scrq" Header="生产日期" Align="Center" Sortable="false">
- <Editor>
- <ext:DateField ID="TextField9" runat="server" />
- </Editor>
- <Renderer Fn="Ext.util.Format.dateRenderer('Y-m-d')" />
- </ext:Column>
- <ext:Column ColumnID="dqr" DataIndex="dqr" Header="到期日" Align="Center" Sortable="false">
- <Editor>
- <ext:DateField ID="TextField10" runat="server" />
- </Editor>
- <Renderer Fn="Ext.util.Format.dateRenderer('Y-m-d')" />
- </ext:Column>
- <ext:Column ColumnID="bz" DataIndex="bz" Header="备注" Align="Center" Sortable="false">
- <Editor>
- <ext:TextField ID="TextField11" runat="server" />
- </Editor>
- </ext:Column>
- </Columns>
- </ColumnModel>
- <BottomBar>
- <ext:PagingToolbar runat="server" ID="PagingToolbar1" PageSize="20" StoreID="StoreDeptDetailList">
- </ext:PagingToolbar>
- </BottomBar>
- <SelectionModel>
- <ext:RowSelectionModel ID="RowSelectionModel1" runat="server">
- </ext:RowSelectionModel>
- </SelectionModel>
- <LoadMask ShowMask="true" />
- </ext:GridPanel>
- </Items>
- </ext:Panel>
- </Items>
- </ext:Viewport>
复制代码
后台代码
- DataTable dt = new DataTable();
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack && !X.IsAjaxRequest)
- {
- BuildTree(this.treePanel.Root);
- Hidden();
- }
- }
- #region 创建树
- //添加节点
- private Ext.Net.TreeNodeCollection BuildTree(Ext.Net.TreeNodeCollection nodes)
- {
- try
- {
- if (nodes == null)
- {
- nodes = new Ext.Net.TreeNodeCollection();
- }
- dt = wzflBLL.Instance.getALlwzml();
- DataRow[] drx = dt.Select(" FatherCode=''");
- Ext.Net.TreeNode root = new Ext.Net.TreeNode();
- root.NodeID = drx[0]["wzdm"].ToString();
- root.Text = drx[0]["wzmc"].ToString();
- root.Qtip = drx[0]["wzmc"].ToString();
- root.Expanded = true;
- root.Draggable = false;
- root.HrefTarget = drx[0]["wzdm"].ToString();
- nodes.Add(root);
- //添加相应子节点
- this.AddNodes(root);
- //ResourceManager1.AddScript("RefreshTree();");
- return nodes;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- //添加子节点
- private void AddNodes(Ext.Net.TreeNode parent)
- {
- DataRow[] drx = dt.Select();
- drx = dt.Select("FatherCode='" + parent.NodeID + "'");
- if (drx.Length == 0)
- {
- return;
- }
- foreach (DataRow dr in drx)
- {
- Ext.Net.TreeNode node = new Ext.Net.TreeNode();
- node.NodeID = dr["wzdm"].ToString();
- node.Text = dr["wzmc"].ToString();
- node.Qtip = dr["wzmc"].ToString();
- node.HrefTarget = dr["wzdm"].ToString();
- parent.Nodes.Add(node);
- AddNodes(node);
- }
- }
- #endregion
- //NODE点击事件
- [DirectMethod]
- public void NodeClick(string nodeID)
- {
- hdPid.Text = nodeID;
- String wzdm = "";
- //根据选中的树节点 来动态隐藏列
- if (hdPid.Text != "")
- {
- wzdm = wzmxBLL.getMaxFahterCode(hdPid.Text);
- }
- if (wzdm == "3")
- {
- gpFuncsList.ColumnModel.SetHidden(8, false);
- gpFuncsList.ColumnModel.SetHidden(9, false);
- gpFuncsList.ColumnModel.SetHidden(10, false);
- gpFuncsList.ColumnModel.SetHidden(6, true);
- }
- else if (wzdm == "2")
- {
- gpFuncsList.ColumnModel.SetHidden(6, false);
- gpFuncsList.ColumnModel.SetHidden(8, true);
- gpFuncsList.ColumnModel.SetHidden(9, true);
- gpFuncsList.ColumnModel.SetHidden(10, true);
- }
- else
- {
- gpFuncsList.ColumnModel.SetHidden(6, true);
- gpFuncsList.ColumnModel.SetHidden(8, true);
- gpFuncsList.ColumnModel.SetHidden(9, true);
- gpFuncsList.ColumnModel.SetHidden(10, true);
- }
- List<wzmxEntity> list = wzmxBLL.Instance.GetEntities(" where 1=1 and fldm='" + nodeID + "'");
- StoreDeptDetailList.DataSource = list;
- StoreDeptDetailList.DataBind();
- }
- protected void Hidden()
- {
- gpFuncsList.ColumnModel.SetHidden(6, true);
- gpFuncsList.ColumnModel.SetHidden(8, true);
- gpFuncsList.ColumnModel.SetHidden(9, true);
- gpFuncsList.ColumnModel.SetHidden(10, true);
- }
- protected void StoreChanged(object sender, BeforeStoreChangedEventArgs e)
- {
- ChangeRecords<wzmxEntity> persons = e.DataHandler.ObjectData<wzmxEntity>();
- foreach (wzmxEntity created in persons.Created)
- {
- wzmxEntity entity = created;
- entity.dwdm = Request.Cookies["danwei"].Value.Trim();
- entity.bmdm = Request.Cookies["bumen"].Value.Trim();
- entity.fldm = hdPid.Text;
- entity.wzdm = wzrkmlDal.GetNumber("008", "");
- wzmxBLL.Instance.Insert(ref entity);
- }
- foreach (wzmxEntity updated in persons.Updated)
- {
- wzmxBLL.Instance.Update(updated);
- }
- e.Cancel = true;
- }
- }
http://www.ext.net.cn/forum.php?mod=viewthread&tid=1498&extra=page%3D4
[Ext.Net]TreePanel+gridPanel实例的更多相关文章
- [Ext.Net]TreePanel 异步加载数据
异步加载数据指的是页面加载的时候只显示根目录,点击根目录再去加载其子目录. 下面就来介绍下这种异步加载的树结构要怎么实现 现将例子的图 QQ图片20131225134353.jpg (12.1 KB, ...
- Ext.Net 复制GridPanel的数据
Ext.Net 复制GridPanel的数据 2013-11-28 09:50:04| 分类: Ext.net | 标签: |举报 |字号大中小 订阅 CSS: <styletype ...
- [JAVASCRIPT][EXTJS]直接用JSON创建树形控件(Ext.tree.TreePanel )(转)
直接用JSON创建树形控件(Ext.tree.TreePanel ) 1.创建多个根节点的树形 2.直接使用JsonList创建树形 <!DOCTYPE HTML PUBLIC "-/ ...
- Ext.tree.TreePanel 属性详解
Ext.tree.TreePanel 属性详解 2013-06-09 11:02:47| 分类: ExtJs|举报|字号 订阅 原文地址:http://blog.163.com/zzf_fly/b ...
- Ext.Net TreePanel 修改Icon图标
分类: Ext.Net2012-09-24 13:44 1779人阅读 评论(0) 收藏 举报 webformserverextassemblyxhtmlobject 1.默认icon 2.自定义ic ...
- ext.net 实现gridpanel checkbox锁定
<%@ Page Language="C#" %> <%@ Register Assembly="Ext.Net" Namespace=&qu ...
- Extjs-树 Ext.tree.TreePanel 动态加载数据
先上效果图 1.说明Ext.tree.Panel 控件是树形控件,大家知道树形结构在软件开发过程中的应用是很广泛的,树形控件的数据有本地数据.服务器端返回的数据两种.对于本地数据的加载,在extjs的 ...
- Ext JS 6开发实例(四) :调整主视图
上文把主界面设置好,但是主视图因为界面的微调出现了显示问题,本文将把它调整好了. 打开app/view/main/Main.js,可以看到主视图是派生于标签面板(Ext.tab.Panel)的.在视图 ...
- Ext JS 6开发实例(三) :主界面设计
在上文中,已经将CMD创建的应用程序导入到项目里了,而且也看到默认的主界面了,今天的主要工作就是修改这个主界面,以符合项目的需要.除了设计主界面,还有一些其他的东西需要配置一下. 添加本地化包 打开a ...
随机推荐
- Python中如何将二维列表转换成一维列表
已知:a = [(4,2,3), (5, 9, 1), (7,8,9)]希望将二维列表转换成一维列表:["4,2,3", "5, 9, 1", "7, ...
- 彻底理解Oracle中的集合操作与复合查询
--Oracle中的复合查询 复合查询:包含集合运算(操作)的查询 常见的集合操作有: union: 两个查询的并集(无重复行.按第一个查询的第一列升序排序) union all:两个查询的并集(有重 ...
- SQL Server 虚拟化(1)——虚拟化简介
本文属于SQL Server虚拟化系列 前言: 现代系统中,虚拟化越来越普遍,如果缺乏对虚拟化工作原理的理解,那么DBA在解决性能问题比如降低资源争用.提高备份还原速度等操作时就会出现盲点.所以基于本 ...
- Bootstrap3 栅格系统-实例:多余的列(column)将另起一行排列
如果在一个 .row 内包含的列(column)大于12个,包含多余列(column)的元素将作为一个整体单元被另起一行排列. <div class="row"> &l ...
- Thread Pools
许多程序会动态创建数十个设置上百个线程.举个例子,一个web服务器可能在每一个新到来的请求时创建一个新线程,然后在请求完成后将其终止. 然而,创建一个新线程将会带来一定的耗费:它需要在内核中创建自身必 ...
- Xcode Organizational Identifiers
操作系统(不管是iOS或是OS X)使用bundle标识去唯一标识你的应用.Bundle标识由一个组织id和你App的名字组成. 一般的,组织id是你域名的反转.如果你的域名是example.com那 ...
- 搭建ejabberd集群
搭建ejabberd集群(金庆的专栏 2016.8)以2台机器搭建一个ejabberd集群.2台机器都是外网一块网卡,内网另一块网卡.新建一个域名,添加2台机器的外网IP.分别用源码安装ejabber ...
- Thread 方法
Thread类的一些被Thread对象调用的方法: 1 public void start() 使该线程开始执行:Java 虚拟机调用该线程的 run 方法. 2 public void run() ...
- Freemarker 浅析
今天分享一下一个模板语言的使用,它就是Freemarker,有点类似与前些日子做Python的Django中的模板语言,其实原理上都是相似的.所以这里就不对那些基础性的语法类的直至进行讲解了,就拿几个 ...
- Android开源框架ViewPagerIndicator的基本使用
转载本博客请注明出处:点击打开链接 http://blog.csdn.net/qq_32059827/article/details/52495647 很多新闻资讯类的app都有一些共性,那就是 ...