@小花要完整例子,尝试一下图文并茂,力求完整。

gridPanel TreePanel.JPG (27.49 KB, 下载次数: 16)

下载附件  保存到相册

2013-1-6 11:24 上传

前台代码

  1. <ext:ResourceManager ID="ResourceManager1" DirectMethodNamespace="RM" runat="server" />
  2. <ext:Store ID="StoreDeptDetailList" OnBeforeStoreChanged="StoreChanged" runat="server">
  3. <Reader>
  4. <ext:JsonReader IDProperty="ID">
  5. <Fields>
  6. <ext:RecordField Name="ID" />
  7. <ext:RecordField Name="wzdm" />
  8. ... ....
  9. <ext:RecordField Name="bz" />
  10. </Fields>
  11. </ext:JsonReader>
  12. </Reader>
  13. </ext:Store>
  14. <ext:Viewport ID="Viewport1" runat="server" Layout="border">
  15. <Items>
  16. <ext:Panel ID="Panel1" runat="server" Region="West" Split="true" Width="225" Border="false"
  17. AutoScroll="true">
  18. <Content>
  19. <ext:TreePanel ID="treePanel" runat="server" Border="false">
  20. <Root>
  21. </Root>
  22. <Listeners>
  23. <Click Handler="e.stopEvent();RM.NodeClick(node.id);" />
  24. </Listeners>
  25. </ext:TreePanel>
  26. </Content>
  27. </ext:Panel>
  28. <ext:Panel ID="PanelCenter" runat="server" Region="Center" Layout="Fit" Cls="ViewPortRight"
  29. ButtonAlign="Right" Width="270" Header="false" Title="物资明细" Icon="TableGear"
  30. Border="false">
  31. <Items>
  32. <ext:GridPanel ID="gpFuncsList" runat="server" StripeRows="true" ClicksToEdit="0"
  33. Header="false" Height="600" StoreID="StoreDeptDetailList" Border="true" TrackMouseOver="true">
  34. <TopBar>
  35. <ext:Toolbar ID="Toolbar2" runat="server" AutoWidth="true">
  36. <Items>
  37. <ext:Label runat="server" ID="lblTitle">
  38. </ext:Label>
  39. <ext:ToolbarFill ID="ToolbarFill1" runat="server" />
  40. <ext:Button ID="btnAdd" runat="server" Text="新增" Icon="Add">
  41. <Listeners>
  42. <Click Handler="#{gpFuncsList}.insertRecord();" />
  43. </Listeners>
  44. </ext:Button>
  45. <ext:Button ID="btnDelete" runat="server" Text="删除" Icon="Delete">
  46. <Listeners>
  47. <Click Handler="#{gpFuncsList}.deleteSelected();" />
  48. </Listeners>
  49. </ext:Button>
  50. <ext:Button ID="btnSave" runat="server" Text="保存" Icon="Disk">
  51. <Listeners>
  52. <Click Handler="#{gpFuncsList}.save();" />
  53. </Listeners>
  54. </ext:Button>
  55. </Items>
  56. </ext:Toolbar>
  57. </TopBar>
  58. <ColumnModel ID="ColumnModel1" runat="server">
  59. <Columns>
  60. <ext:Column ColumnID="wzmc" DataIndex="wzmc" Header="物资名称" Align="Center" Sortable="false">
  61. <Editor>
  62. <ext:TextField ID="TextField1" runat="server" />
  63. </Editor>
  64. </ext:Column>
  65. <ext:Column ColumnID="ggxh" DataIndex="ggxh" Header="规格型号" Align="Center" Sortable="false">
  66. <Editor>
  67. <ext:TextField ID="TextField2" runat="server" />
  68. </Editor>
  69. </ext:Column>
  70. <ext:Column ColumnID="bcdd" DataIndex="bcdd" Header="保存地点" Align="Center" Sortable="false">
  71. <Editor>
  72. <ext:TextField ID="TextField3" runat="server" />
  73. </Editor>
  74. </ext:Column>
  75. <ext:Column ColumnID="sccj" DataIndex="sccj" Header="生产厂家" Align="Center" Sortable="false">
  76. <Editor>
  77. <ext:TextField ID="TextField4" runat="server" />
  78. </Editor>
  79. </ext:Column>
  80. <ext:Column ColumnID="jxs" DataIndex="jxs" Header="经销商" Align="Center" Sortable="false">
  81. <Editor>
  82. <ext:TextField ID="TextField5" runat="server" />
  83. </Editor>
  84. </ext:Column>
  85. <ext:Column ColumnID="zzs" DataIndex="zzs" Header="制造商" Align="Center" Sortable="false">
  86. <Editor>
  87. <ext:TextField ID="TextField6" runat="server" />
  88. </Editor>
  89. </ext:Column>
  90. <ext:Column ColumnID="isny" DataIndex="isny" Header="是否为耐用品" Align="Center" Sortable="false">
  91. <Editor>
  92. <ext:ComboBox ID="TextField7" runat="server">
  93. <Items>
  94. <ext:ListItem Text="是" Value="是" />
  95. <ext:ListItem Text="否" Value="否" />
  96. </Items>
  97. </ext:ComboBox>
  98. </Editor>
  99. </ext:Column>
  100. <ext:Column ColumnID="jldw" DataIndex="jldw" Header="计量单位" Align="Center" Sortable="false">
  101. <Editor>
  102. <ext:ComboBox ID="ComboBox4" runat="server">
  103. <Items>
  104. <ext:ListItem Text="方" Value="方" />
  105. <ext:ListItem Text="公斤" Value="公斤" />
  106. <ext:ListItem Text="发" Value="发" />
  107. <ext:ListItem Text="根" Value="根" />
  108. <ext:ListItem Text="台" Value="台" />
  109. <ext:ListItem Text="灯" Value="灯" />
  110. <ext:ListItem Text="吨" Value="顿" />
  111. <ext:ListItem Text="米" Value="米" />
  112. <ext:ListItem Text="鞋" Value="鞋" />
  113. <ext:ListItem Text="套" Value="套" />
  114. <ext:ListItem Text="块" Value="块" />
  115. <ext:ListItem Text="辆" Value="辆" />
  116. <ext:ListItem Text="个" Value="个" />
  117. <ext:ListItem Text="把" Value="把" />
  118. </Items>
  119. </ext:ComboBox>
  120. </Editor>
  121. </ext:Column>
  122. <ext:Column ColumnID="cph" DataIndex="cph" Header="车牌号" Align="Center" Sortable="false">
  123. <Editor>
  124. <ext:TextField ID="TextField12" runat="server" />
  125. </Editor>
  126. </ext:Column>
  127. <ext:Column ColumnID="djgl" DataIndex="djgl" Header="电机功率" Sortable="false">
  128. <Editor>
  129. <ext:TextField ID="TextField13" runat="server" />
  130. </Editor>
  131. </ext:Column>
  132. <ext:Column ColumnID="zjs" DataIndex="jzs" Header="间(座)数" Align="Center" Sortable="false">
  133. <Editor>
  134. <ext:NumberField ID="TextField14" runat="server" />
  135. </Editor>
  136. </ext:Column>
  137. <ext:Column ColumnID="nx" DataIndex="nx" Header="使用年限" Align="Center" Sortable="false">
  138. <Editor>
  139. <ext:SpinnerField ID="SpinnerField2" runat="server" MinValue="1" MaxValue="100" AllowDecimals="true"
  140. DecimalPrecision="1" Accelerate="true" />
  141. </Editor>
  142. </ext:Column>
  143. <ext:Column ColumnID="scrq" DataIndex="scrq" Header="生产日期" Align="Center" Sortable="false">
  144. <Editor>
  145. <ext:DateField ID="TextField9" runat="server" />
  146. </Editor>
  147. <Renderer Fn="Ext.util.Format.dateRenderer('Y-m-d')" />
  148. </ext:Column>
  149. <ext:Column ColumnID="dqr" DataIndex="dqr" Header="到期日" Align="Center" Sortable="false">
  150. <Editor>
  151. <ext:DateField ID="TextField10" runat="server" />
  152. </Editor>
  153. <Renderer Fn="Ext.util.Format.dateRenderer('Y-m-d')" />
  154. </ext:Column>
  155. <ext:Column ColumnID="bz" DataIndex="bz" Header="备注" Align="Center" Sortable="false">
  156. <Editor>
  157. <ext:TextField ID="TextField11" runat="server" />
  158. </Editor>
  159. </ext:Column>
  160. </Columns>
  161. </ColumnModel>
  162. <BottomBar>
  163. <ext:PagingToolbar runat="server" ID="PagingToolbar1" PageSize="20" StoreID="StoreDeptDetailList">
  164. </ext:PagingToolbar>
  165. </BottomBar>
  166. <SelectionModel>
  167. <ext:RowSelectionModel ID="RowSelectionModel1" runat="server">
  168. </ext:RowSelectionModel>
  169. </SelectionModel>
  170. <LoadMask ShowMask="true" />
  171. </ext:GridPanel>
  172. </Items>
  173. </ext:Panel>
  174. </Items>
  175. </ext:Viewport>

复制代码

后台代码

  1. DataTable dt = new DataTable();
  2. protected void Page_Load(object sender, EventArgs e)
  3. {
  4. if (!IsPostBack && !X.IsAjaxRequest)
  5. {
  6. BuildTree(this.treePanel.Root);
  7. Hidden();
  8. }
  9. }
  10. #region 创建树
  11. //添加节点
  12. private Ext.Net.TreeNodeCollection BuildTree(Ext.Net.TreeNodeCollection nodes)
  13. {
  14. try
  15. {
  16. if (nodes == null)
  17. {
  18. nodes = new Ext.Net.TreeNodeCollection();
  19. }
  20. dt = wzflBLL.Instance.getALlwzml();
  21. DataRow[] drx = dt.Select(" FatherCode=''");
  22. Ext.Net.TreeNode root = new Ext.Net.TreeNode();
  23. root.NodeID = drx[0]["wzdm"].ToString();
  24. root.Text = drx[0]["wzmc"].ToString();
  25. root.Qtip = drx[0]["wzmc"].ToString();
  26. root.Expanded = true;
  27. root.Draggable = false;
  28. root.HrefTarget = drx[0]["wzdm"].ToString();
  29. nodes.Add(root);
  30. //添加相应子节点
  31. this.AddNodes(root);
  32. //ResourceManager1.AddScript("RefreshTree();");
  33. return nodes;
  34. }
  35. catch (Exception ex)
  36. {
  37. throw ex;
  38. }
  39. }
  40. //添加子节点
  41. private void AddNodes(Ext.Net.TreeNode parent)
  42. {
  43. DataRow[] drx = dt.Select();
  44. drx = dt.Select("FatherCode='" + parent.NodeID + "'");
  45. if (drx.Length == 0)
  46. {
  47. return;
  48. }
  49. foreach (DataRow dr in drx)
  50. {
  51. Ext.Net.TreeNode node = new Ext.Net.TreeNode();
  52. node.NodeID = dr["wzdm"].ToString();
  53. node.Text = dr["wzmc"].ToString();
  54. node.Qtip = dr["wzmc"].ToString();
  55. node.HrefTarget = dr["wzdm"].ToString();
  56. parent.Nodes.Add(node);
  57. AddNodes(node);
  58. }
  59. }
  60. #endregion
  61. //NODE点击事件
  62. [DirectMethod]
  63. public void NodeClick(string nodeID)
  64. {
  65. hdPid.Text = nodeID;
  66. String wzdm = "";
  67. //根据选中的树节点 来动态隐藏列
  68. if (hdPid.Text != "")
  69. {
  70. wzdm = wzmxBLL.getMaxFahterCode(hdPid.Text);
  71. }
  72. if (wzdm == "3")
  73. {
  74. gpFuncsList.ColumnModel.SetHidden(8, false);
  75. gpFuncsList.ColumnModel.SetHidden(9, false);
  76. gpFuncsList.ColumnModel.SetHidden(10, false);
  77. gpFuncsList.ColumnModel.SetHidden(6, true);
  78. }
  79. else if (wzdm == "2")
  80. {
  81. gpFuncsList.ColumnModel.SetHidden(6, false);
  82. gpFuncsList.ColumnModel.SetHidden(8, true);
  83. gpFuncsList.ColumnModel.SetHidden(9, true);
  84. gpFuncsList.ColumnModel.SetHidden(10, true);
  85. }
  86. else
  87. {
  88. gpFuncsList.ColumnModel.SetHidden(6, true);
  89. gpFuncsList.ColumnModel.SetHidden(8, true);
  90. gpFuncsList.ColumnModel.SetHidden(9, true);
  91. gpFuncsList.ColumnModel.SetHidden(10, true);
  92. }
  93. List<wzmxEntity> list = wzmxBLL.Instance.GetEntities(" where 1=1 and fldm='" + nodeID + "'");
  94. StoreDeptDetailList.DataSource = list;
  95. StoreDeptDetailList.DataBind();
  96. }
  97. protected void Hidden()
  98. {
  99. gpFuncsList.ColumnModel.SetHidden(6, true);
  100. gpFuncsList.ColumnModel.SetHidden(8, true);
  101. gpFuncsList.ColumnModel.SetHidden(9, true);
  102. gpFuncsList.ColumnModel.SetHidden(10, true);
  103. }
  104. protected void StoreChanged(object sender, BeforeStoreChangedEventArgs e)
  105. {
  106. ChangeRecords<wzmxEntity> persons = e.DataHandler.ObjectData<wzmxEntity>();
  107. foreach (wzmxEntity created in persons.Created)
  108. {
  109. wzmxEntity entity = created;
  110. entity.dwdm = Request.Cookies["danwei"].Value.Trim();
  111. entity.bmdm = Request.Cookies["bumen"].Value.Trim();
  112. entity.fldm = hdPid.Text;
  113. entity.wzdm = wzrkmlDal.GetNumber("008", "");
  114. wzmxBLL.Instance.Insert(ref entity);
  115. }
  116. foreach (wzmxEntity updated in persons.Updated)
  117. {
  118. wzmxBLL.Instance.Update(updated);
  119. }
  120. e.Cancel = true;
  121. }
  122. }

http://www.ext.net.cn/forum.php?mod=viewthread&tid=1498&extra=page%3D4

[Ext.Net]TreePanel+gridPanel实例的更多相关文章

  1. [Ext.Net]TreePanel 异步加载数据

    异步加载数据指的是页面加载的时候只显示根目录,点击根目录再去加载其子目录. 下面就来介绍下这种异步加载的树结构要怎么实现 现将例子的图 QQ图片20131225134353.jpg (12.1 KB, ...

  2. Ext.Net 复制GridPanel的数据

    Ext.Net 复制GridPanel的数据 2013-11-28 09:50:04|  分类: Ext.net |  标签: |举报 |字号大中小 订阅     CSS: <styletype ...

  3. [JAVASCRIPT][EXTJS]直接用JSON创建树形控件(Ext.tree.TreePanel )(转)

    直接用JSON创建树形控件(Ext.tree.TreePanel ) 1.创建多个根节点的树形 2.直接使用JsonList创建树形 <!DOCTYPE HTML PUBLIC "-/ ...

  4. Ext.tree.TreePanel 属性详解

    Ext.tree.TreePanel 属性详解 2013-06-09 11:02:47|  分类: ExtJs|举报|字号 订阅  原文地址:http://blog.163.com/zzf_fly/b ...

  5. Ext.Net TreePanel 修改Icon图标

    分类: Ext.Net2012-09-24 13:44 1779人阅读 评论(0) 收藏 举报 webformserverextassemblyxhtmlobject 1.默认icon 2.自定义ic ...

  6. ext.net 实现gridpanel checkbox锁定

    <%@ Page Language="C#" %> <%@ Register Assembly="Ext.Net" Namespace=&qu ...

  7. Extjs-树 Ext.tree.TreePanel 动态加载数据

    先上效果图 1.说明Ext.tree.Panel 控件是树形控件,大家知道树形结构在软件开发过程中的应用是很广泛的,树形控件的数据有本地数据.服务器端返回的数据两种.对于本地数据的加载,在extjs的 ...

  8. Ext JS 6开发实例(四) :调整主视图

    上文把主界面设置好,但是主视图因为界面的微调出现了显示问题,本文将把它调整好了. 打开app/view/main/Main.js,可以看到主视图是派生于标签面板(Ext.tab.Panel)的.在视图 ...

  9. Ext JS 6开发实例(三) :主界面设计

    在上文中,已经将CMD创建的应用程序导入到项目里了,而且也看到默认的主界面了,今天的主要工作就是修改这个主界面,以符合项目的需要.除了设计主界面,还有一些其他的东西需要配置一下. 添加本地化包 打开a ...

随机推荐

  1. OpenCV设置摄像头分辨率及全屏显示

    OpenCV3.0下 设置摄像头分辨率为1920*1440,并全屏显示图像窗口. int _tmain(int argc, _TCHAR* argv[]) { Mat frame; VideoCapt ...

  2. Radio Station

    B. Radio Station time limit per test:  2 seconds memory limit per test:  256 megabytes input: standa ...

  3. 第一个Angular2的样例

    欢迎跟我一起学习Angular2 本文根据angular2官网手动敲码得来: 本文地址:http://blog.csdn.net/sushengmiyan 本文作者:苏生米沿 - 开发环境搭建 - 配 ...

  4. Cassandra Secondary Index 介绍

    摘要 本文主要介绍cassandra中的索引,物化视图,有些知识点需要对cassandra有基本的认识才能理解.比如数据在cassandra节点中如何分布.如果有不明白的地方可以看本专栏之前文章.或者 ...

  5. Sublime text 添加lua

    tools ->build system->new build system... 输入: { "cmd": ["C:\\lua\\lua53.exe&quo ...

  6. Android双击退出

    重写返回键 private long tempTime = 0; /** * 双击退出 */ @Override public void onBackPressed() { long firstCli ...

  7. 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: ...

  8. 剑指Offer——咪咕笔试题+知识点总结

    剑指Offer--咪咕笔试题+知识点总结 情景回顾 时间:2016.10.09 15:00-16:30 地点:山东省网络环境智能计算技术重点实验室 事件:咪咕笔试 知识点总结 1.Html设置格式贵阳 ...

  9. React Native之ViewPagerAndroid 组件

    概述 今天我们来讲解一下关于 ViewPager 的使用,它是一个允许子视图左右滚动翻页的容器.我们知道在Android开发中系统有ViewPager这个组件,作用是实现滚动翻页的,在RN中也是有这么 ...

  10. Dynamics CRM2013 在Visual Studio中开启脚本的Xrm.Page智能提示

    前面篇博文http://blog.csdn.net/vic0228/article/details/49663751提到了通过引用XrmPage-vsdoc.js文件来启用Xrm.Page的智能提示, ...