删除时候ajax传当前选中的数据的ID到后台,删除后刷新表格 (reload)。
解决方案 »
- 很郁闷 ,ie下 iframe插入图片问题
- 救命啊……求最新的日历控件,急求~~~
- flash的死连接导致页面不会触发onload事件有没有办法解决?
- 如何做隐藏?
- 关于document.write()~
- 关于鼠标事件获取坐标的问题和图片大小的问题?加急
- 急、急、急请大家帮忙!!!
- 如何用javascript设置窗体大小
- 求助 找web editor 在线编辑 可以所见即所得的哪种
- ■■jscript中把string转换成int型应当用什么函数?■■
- JavaScript编译时Uncaught TypeError: undefined is not a function
- js中toString和valueOf的区别?
if (row) {
var rowIndex = $('#t1').datagrid('getRowIndex', row);
$('#t1').datagrid('deleteRow', rowIndex);
$('#t1').datagrid('reload');//删除后重新加载下
}
width:810,
height:400,
idField:'xsbh',
url:'',
columns:[[
{field:'xsbh',title:'编号',width:80},
{field:'opt',title:'操作',width:100,align:'center',
formatter:function(value,rec,index){
var delete = '<a href="#" mce_href="#" onclick="del(\''+ index +'\')">删除</a> ';
return delete ;
}
}
]],
pagination:true
});
}) 红色部分加上
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Row Editing DataGrid - jQuery EasyUI Demo</title>
<link rel="stylesheet" type="text/css" href="../../themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="../../themes/icon.css">
<link rel="stylesheet" type="text/css" href="../demo.css">
<script type="text/javascript" src="../../jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="../../jquery.easyui.min.js"></script>
</head>
<body>
<h2>Row Editing DataGrid</h2>
<div class="demo-info">
<div class="demo-tip icon-tip"></div>
<div>Click the row to start editing.</div>
</div>
<div style="margin:10px 0;"></div>
<table id="dg" class="easyui-datagrid" title="Row Editing DataGrid" style="width:700px;height:auto"
data-options="
iconCls: 'icon-edit',
singleSelect: true,
toolbar: '#tb',
url: '../datagrid/datagrid_data1.json',
onClickRow: onClickRow
">
<thead>
<tr>
<th data-options="field:'itemid',width:80">Item ID</th>
<th data-options="field:'productid',width:100,
formatter:function(value,row){
return row.productname;
},
editor:{
type:'combobox',
options:{
valueField:'productid',
textField:'productname',
url:'../datagrid/products.json',
required:true
}
}">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:'text'">Attribute</th>
<th data-options="field:'status',width:60,align:'center',editor:{type:'checkbox',options:{on:'P',off:''}}">Status</th>
</tr>
</thead>
</table> <div id="tb" style="height:auto">
<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="append()">Append</a>
<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true" onclick="remove()">Remove</a>
<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-save',plain:true" onclick="accept()">Accept</a>
<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-undo',plain:true" onclick="reject()">Reject</a>
<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" onclick="getChanges()">GetChanges</a>
</div>
<script type="text/javascript">
var editIndex = undefined;
function endEditing(){
if (editIndex == undefined){return true}
if ($('#dg').datagrid('validateRow', editIndex)){
var ed = $('#dg').datagrid('getEditor', {index:editIndex,field:'productid'});
var productname = $(ed.target).combobox('getText');
$('#dg').datagrid('getRows')[editIndex]['productname'] = productname;
$('#dg').datagrid('endEdit', editIndex);
editIndex = undefined;
return true;
} else {
return false;
}
}
function onClickRow(index){
if (editIndex != index){
if (endEditing()){
$('#dg').datagrid('selectRow', index)
.datagrid('beginEdit', index);
editIndex = index;
} else {
$('#dg').datagrid('selectRow', editIndex);
}
}
}
function append(){
if (endEditing()){
$('#dg').datagrid('appendRow',{status:'P'});
editIndex = $('#dg').datagrid('getRows').length-1;
$('#dg').datagrid('selectRow', editIndex)
.datagrid('beginEdit', editIndex);
}
}
function remove(){
if (editIndex == undefined){return}
$('#dg').datagrid('cancelEdit', editIndex)
.datagrid('deleteRow', editIndex);
editIndex = undefined;
}
function accept(){
if (endEditing()){
$('#dg').datagrid('acceptChanges');
}
}
function reject(){
$('#dg').datagrid('rejectChanges');
editIndex = undefined;
}
function getChanges(){
var rows = $('#dg').datagrid('getChanges');
alert(rows.length+' rows are changed!');
}
</script>
</body>
</html>
var rows = $('#t1').datagrid("getRows");
$('#t1').datagrid("loadData", rows);
var deleted = $('#t1').datagrid('getChanges', "deleted");
var rows = dg.datagrid('getChecked');
if (rows.length >= 1) {
dg.datagrid('deleteRow', dg.datagrid('getRowIndex', rows[0]));
edit_rows_length -= 1;
} else {
return false;
}
}
var rows = dg.datagrid('getChecked');
if (rows.length >= 1) {
dg.datagrid('deleteRow', dg.datagrid('getRowIndex', rows[0]));
edit_rows_length -= 1;
} else {
return false;
}
}