一起跟随小编过来取来吧
取来时候我们的后台系统表单比较冬夏青青,做过进销存或者一些销售订单的都取来取来过感觉。
虽然Easyui Datagrid提供了行内编辑,但是取来灵活,但是我们稍微取来一下来取来批量编辑,批量删除,批量取来的效果。
第一:取来行的取来事件
function onClickCell{ if { if {
$.datagrid
.datagrid;
var ed = $.datagrid;
if {
.data ? $.textbox : $;
}
editIndex = index; } else {
setTimeout {
$.datagrid;
}, 0; } } }
第二:删除事件
function removeit{ if {return} $.datagrid; $.datagrid
.datagrid; editIndex = undefined; }
第三:取来事件,取来菜单的Append和+号
function append{ var index = $.datagrid.datagrid; if
index = 0; $.datagrid'>+<a> <a href='javascript:removeit'>-<a>','P'} }; }
第四:保存
{ if { var $dg = $; var rows = $dg.datagrid; if {
var inserted = $dg.datagrid;
var deleted = $dg.datagrid;
var updated = $dg.datagrid;
var effectRow = new Object;
if {
effectRow = JSON.stringify;
}
if {
effectRow = JSON.stringify;
}
if {
effectRow = JSON.stringify;
}
//alert;
//alert;
//alert; } } //$.post { // if { // $dg.datagrid; // bindData; // } //}, 'JSON'.error { // $.messager.alert; //}; }最后我们可以获得,上面操作的,所取来:取来的行,删除的行,更新的行。把数据取来到数据后台进行处理。
最后你还需要对数据进行取来校验,可以获得数据,在控制台取来:
console.log;console.log;console.log;
总结:
最后完整代码:
<!DOCTYPE html><html><head> <meta charset='UTF-8'> <title>Row Editing in DataGrid - jQuery EasyUI Demo</title> <link type='text/css' href='../../themes/default/easyui.css' > <link type='text/css' href='../../themes/icon.css' > <link type='text/css' href='../demo.css' > <script type='text/javascript' src='../../jquery.min.js'></script> <script type='text/javascript' src='../../jquery.easyui.min.js'></script></head><body> <h2>Row Editing in DataGrid</h2> <p>Click the row to start editing.</p> <div></div> <table title='Row Editing in DataGrid' data-options=' iconCls: 'icon-edit', singleSelect: true, toolbar: '#tb', url: 'datagrid_data1.json', method: 'get', onClickCell: onClickCell, onEndEdit: onEndEdit '> <thead> <tr> <th data-options='field:'oper',width:80'>操作</th> <th data-options='field:'itemid',width:80'>Item ID</th> <th data-options='field:'productid',width:100, formatter:function{ return row.productname; }, editor:{', options:{ valueField:'productid', textField:'productname', method:'get', url:'products.json', } }'>Product</th> <th data-options='field:'listprice',width:80,align:'right',editor:{type:'numberbox',options:{precision:1}}'>List Price</th> <th data-options='field:'unitcost',width:80,align:'right',editor:'numberbox''>Unit Cost</th> <th data-options='field:'attr1',width:250,editor:'textbox''>Attribute</th> <th data-',width:60,align:'center',editor:{type:'checkbox',options:{on:'P',off:''}}'>;/th> </tr> </thead> </table> <div> <a href='javascript:void' data-options='iconCls:'icon-add',plain:true'>Append</a> <a href='javascript:void' data-options='iconCls:'icon-remove',plain:true'>Remove</a> <a href='javascript:void' data-options='iconCls:'icon-save','>;/a> <a href='javascript:void' data-options='iconCls:'icon-undo',plain:true'>Reject</a> <a href='javascript:void' data-options='iconCls:'icon-search',plain:true'>GetChanges</a> </div> <script type='text/javascript'> //编辑的行 var editIndex = undefined; function endEditing { if {return true} $.datagrid; editIndex = undefined; return true; } function onClickCell{ if { if { $.datagrid .datagrid; var ed = $.datagrid; if { .data ? $.textbox : $; } editIndex = index; } else { setTimeout { $.datagrid; }, 0; } } } function onEndEdit{ var ed = $.datagrid; row.productname = $; } function append{ var index = $.datagrid.datagrid; if index = 0; $.datagrid'>+<a> <a href='javascript:removeit'>-<a>','P'} }; } function removeit{ if {return} $.datagrid; $.datagrid .datagrid; editIndex = undefined; } { if { var $dg = $; var rows = $dg.datagrid; if { var inserted = $dg.datagrid; var deleted = $dg.datagrid; var updated = $dg.datagrid; var effectRow = new Object; if { effectRow = JSON.stringify; } if { effectRow = JSON.stringify; } if { effectRow = JSON.stringify; } //alert; //alert; //alert; } } //$.post { // if { // $dg.datagrid; // bindData; // } //}, 'JSON'.error { // $.messager.alert; //}; } function reject{ $.datagrid; editIndex = undefined; } function getChanges{ var rows = $.datagrid; alert; } function contains { var i = arr.length; while { if { return true; } } return false; } </script></body></html>以上就是本文的全部内容,希望对大家的学习取来所帮助,也希望大家在取来脚本噬家