jQuery EasyUI DataGrid 可编辑列级联操作
2013-09-09 09:35
429 查看
<script>$(function () { var lastIndex; var $dg = $('#dg'); $dg.datagrid({ width : 600, height : 'auto', title : '可编辑列级联操作', singleSelect : true, idField : 'itemid', url : '/uploads/rs/233/bkf2ntm7/datagrid_data2.json', columns : [[{ field : 'itemid', title : 'Item ID', width : 80 }, { field : 'productid', title : 'Product ID', width : 120, formatter : productFormatter, editor : { type : 'combobox', options : { valueField : 'productid', textField : 'name', data : products, required : true, onChange : function (newValue, oldValue) { //重点在此处 //先获取到当前选中行 //根据当前行获取,当前行的下标 //在根据下标和要获取列的filed获取对应filed的Editor对象 //然后在根据对应的Editor操作 var row = $dg.datagrid('getSelected'); var rindex = $dg.datagrid('getRowIndex', row); var ed = $dg.datagrid('getEditor', { index : rindex, field : 'listprice' }); $(ed.target).numberbox('setValue', '2012'); } } } }, { field : 'listprice', title : 'List Price', width : 80, align : 'right', editor : { type : 'numberbox', options : { precision : 1 } } }, { field : 'unitcost', title : 'Unit Cost', width : 80, align : 'right', editor : 'numberbox' }, { field : 'attr1', title : 'Attribute', width : 250, editor : 'text' }, { field : 'status', title : 'Status', width : 60, align : 'center', editor : { type : 'checkbox', options : { on : 'P', off : '' } } } ]], onBeforeLoad : function () { $(this).datagrid('rejectChanges'); }, onClickRow : function (rowIndex) { if (lastIndex != rowIndex) { $dg.datagrid('endEdit', lastIndex); $dg.datagrid('beginEdit', rowIndex); } lastIndex = rowIndex; } }); }); var products = [{ productid : 'FI-SW-01', name : 'Koi' }, { productid : 'K9-DL-01', name : 'Dalmation' }, { productid : 'RP-SN-01', name : 'Rattlesnake' }, { productid : 'RP-LI-02', name : 'Iguana' }, { productid : 'FL-DSH-01', name : 'Manx' }, { productid : 'FL-DLH-02', name : 'Persian' }, { productid : 'AV-CB-01', name : 'Amazon Parrot' } ]; function productFormatter(value) { for (var i = 0; i < products.length; i++) { if (products[i].productid == value) return products[i].name; } return value; }
相关文章推荐
- jQuery EasyUI DataGrid 编辑列下拉框做级联操作
- jquery Easyui Datagrid实现批量操作(编辑,删除,添加)
- JQuery easyui datagrid 编辑中,js代码设置级联效果
- ASP.NET MVC5+EF6+EasyUI 后台管理系统(82)-Easyui Datagrid批量操作(编辑,删除,添加)
- [转]Jquery easyui开启行编辑模式增删改操作
- ASP.NET MVC5+EF6+EasyUI 后台管理系统(82)-Easyui Datagrid批量操作(编辑,删除,添加)
- [VB.NET]利用vb.net创建一个完全可编辑的DataGrid,从而实现操作Access数据库进行增,删,改的功能,前提是不用任何其他的Button
- JQuery easyui datagrid 单元格编辑时,使用浮动的textarea文本框并进行数据校验
- ASP.NET MVC5+EF6+EasyUI 后台管理系统(82)-Easyui Datagrid批量操作(编辑,删除,添加)
- 给Jquery easyui 的datagrid 每行增加操作链接
- jquery easyui实现datagrid表格向数据库中进行增加,修改和删除操作
- jQuery Easyui DataGrid点击某个单元格即进入编辑状态焦点移开后保存数据
- jQuery EasyUI编辑DataGrid用combobox实现多级联动
- struts2+easyui datagrid可编辑操作及列表数据提交
- jQuery EasyUI编辑DataGrid用combobox实现多级联动
- 在jQuery EasyUI中实现对DataGrid进行编辑
- JQuery easyUi datagrid 中 自定义editor作为列表操作按钮列
- Jquery easyui开启行编辑模式增删改操作
- jQuery EasyUI 数据网格 - 启用行内编辑(转自http://www.runoob.com/jeasyui/jeasyui-datagrid-datagrid12.html)
- 给Jquery easyui 的datagrid 每行增加操作链接