论坛首页 Java企业应用论坛

Easyui可编辑datagrid 为combobox动态赋值

浏览 5664 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2013-09-11  
<div class="iteye-blog-content-contain" style="font-size: 14px;"> <p>1、创建Editor</p> <p> </p> <pre name="code" class="java">{ field: 'categoryname' ,width:100,title:'所属类别' ,editor:{type: 'combobox',options:{ valueField: 'id', textField: 'text', panelHeight: 'auto' }} } </pre> <p> 设置<span style="font-family: monospace; font-size: 1em; line-height: 1.5;">panelHeight: 'auto' 使其不会出现一大片空白!</span></p> <p> </p> <p> </p> <p><span style="font-family: monospace; font-size: 1em; line-height: 1.5;">2、在双击编辑该行是调用ajax 请求后台返回参数</span></p> <p> </p> <pre name="code" class="java">onDblClickRow : function(rowIndex,rowData){ if (editRow != undefined) { $("#admin_gamelist_datagrid").datagrid('endEdit', editRow); } if (editRow == undefined) { $("#admin_gamelist_datagrid").datagrid('beginEdit', rowIndex); editRow = rowIndex; $("#admin_gamelist_datagrid").datagrid('unselectAll'); } synchCategory(rowIndex,rowData); },</pre> <p> <span style="font-family: monospace; font-size: 1em; line-height: 1.5;">synchCategory(rowIndex,rowData);  该方法为请求方法。</span></p> <p> </p> <p> </p> <p><span style="font-family: monospace; font-size: 1em; line-height: 1.5;">3、将返回的值加载进combobox</span></p> <p> </p> <pre name="code" class="js">function synchCategory(rowIndex,rowData){ var jqData; var url = '${pageContext.request.contextPath}/skipController/secCate.do?pid=' +rowData.pcategoryid; var ed = $('#admin_gamelist_datagrid' ).datagrid( 'getEditor',{index:rowIndex,field: 'categoryname' }); $.ajax({ url:url, dataType : 'json', type : 'POST', success: function (data){ jqData = data; $(ed.target).combobox( 'loadData' , jqData); } }); } </pre> <p> </p> <p> </p> <p><span style="font-family: monospace; font-size: 1em; line-height: 1.5;">4、后台处理逻辑</span></p> <p> </p> <pre name="code" class="java">@RequestMapping ("/secCate" ) @ResponseBody public List<Pcategory> cateSecList(String pid){ List<Pcategory> CateSecList = categoryService .getCateSecList(pid); return CateSecList; } </pre> <p> </p> <p> </p> <p><span style="font-family: monospace; font-size: 1em; line-height: 1.5;">5、效果如图所示:</span></p> <p><span style="font-family: monospace; font-size: 1em; line-height: 1.5;"><br><img src="http://dl2.iteye.com/upload/attachment/0089/1960/2dcce1d1-05e0-31d1-a63a-6e8ff261cec7.png" alt=""></span></p> <p><span style="font-family: monospace; font-size: 1em; line-height: 1.5;">效果一<br><br><img src="http://dl2.iteye.com/upload/attachment/0089/1962/3f367a3d-01a9-3ce3-9656-9b7664049a23.png" alt=""><br> <br> 效果二<br> </span></p> <p> </p> <p> </p> </div>
  • 大小: 7.9 KB
  • 大小: 4.9 KB
   发表时间:2013-09-11  
为什么在论坛上显示的就这么乱七八糟。。。
http://jianzh5.iteye.com/blog/1940828
在这里就显示正常!
0 请登录后投票
论坛首页 Java企业应用版

跳转论坛:
Global site tag (gtag.js) - Google Analytics