[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 ...
随机推荐
- OpenCV设置摄像头分辨率及全屏显示
OpenCV3.0下 设置摄像头分辨率为1920*1440,并全屏显示图像窗口. int _tmain(int argc, _TCHAR* argv[]) { Mat frame; VideoCapt ...
- Radio Station
B. Radio Station time limit per test: 2 seconds memory limit per test: 256 megabytes input: standa ...
- 第一个Angular2的样例
欢迎跟我一起学习Angular2 本文根据angular2官网手动敲码得来: 本文地址:http://blog.csdn.net/sushengmiyan 本文作者:苏生米沿 - 开发环境搭建 - 配 ...
- Cassandra Secondary Index 介绍
摘要 本文主要介绍cassandra中的索引,物化视图,有些知识点需要对cassandra有基本的认识才能理解.比如数据在cassandra节点中如何分布.如果有不明白的地方可以看本专栏之前文章.或者 ...
- Sublime text 添加lua
tools ->build system->new build system... 输入: { "cmd": ["C:\\lua\\lua53.exe&quo ...
- Android双击退出
重写返回键 private long tempTime = 0; /** * 双击退出 */ @Override public void onBackPressed() { long firstCli ...
- nginx反向代理和rewrite进行解决跨域问题、去掉url中的一部分字符串,通过nginx正则生成新的url
场景:表面上访问的是http://127.0.0.1:7777/test/xhtml//tpl/app-tpl-webapp/css/base.css, 实际上看的是http://127.0.0.1: ...
- 剑指Offer——咪咕笔试题+知识点总结
剑指Offer--咪咕笔试题+知识点总结 情景回顾 时间:2016.10.09 15:00-16:30 地点:山东省网络环境智能计算技术重点实验室 事件:咪咕笔试 知识点总结 1.Html设置格式贵阳 ...
- React Native之ViewPagerAndroid 组件
概述 今天我们来讲解一下关于 ViewPager 的使用,它是一个允许子视图左右滚动翻页的容器.我们知道在Android开发中系统有ViewPager这个组件,作用是实现滚动翻页的,在RN中也是有这么 ...
- Dynamics CRM2013 在Visual Studio中开启脚本的Xrm.Page智能提示
前面篇博文http://blog.csdn.net/vic0228/article/details/49663751提到了通过引用XrmPage-vsdoc.js文件来启用Xrm.Page的智能提示, ...