$( function() {
//表名称
$('#unitial')
.datagrid(
{
url :'searchUnitialBalance.action',
width :700,
height :400,
nowrap :false,
striped :true,
collapsible :true,
sortName :'SubjectId',
sortOrder :'asc',
remoteSort :false,
columns : [ [ {
field :'BalanceDirection',
title :'余额方向',
width :80
}, {
field :'BorrowBalance',
title :'借,贷方余额',
width :100,
//编辑框
editor: {
hide : false,
type :'numberbox',
options : {
validType :'length[1,10]',
required :true
}
}
}]],onDblClickRow : function() {
//双击得到一行的数据(“余额方向(借,贷)”,“(借,贷)方余额”)
var rr = $('#unitial').datagrid('getSelected');
//判断选中行的某个属性是否可编辑的函数
editor(rr);
}function editor(rr) {
如果我双击的是“借方BalanceDirection ”,则“借方余额BorrowBalance”可编辑;贷方一样
if (row.BalanceDirection == "借方") {
借方余额可编辑
触发的操作应该怎样写???如何进行控制余额是否可编辑
} else{
贷方余额可编辑
}
}
//表名称
$('#unitial')
.datagrid(
{
url :'searchUnitialBalance.action',
width :700,
height :400,
nowrap :false,
striped :true,
collapsible :true,
sortName :'SubjectId',
sortOrder :'asc',
remoteSort :false,
columns : [ [ {
field :'BalanceDirection',
title :'余额方向',
width :80
}, {
field :'BorrowBalance',
title :'借,贷方余额',
width :100,
//编辑框
editor: {
hide : false,
type :'numberbox',
options : {
validType :'length[1,10]',
required :true
}
}
}]],onDblClickRow : function() {
//双击得到一行的数据(“余额方向(借,贷)”,“(借,贷)方余额”)
var rr = $('#unitial').datagrid('getSelected');
//判断选中行的某个属性是否可编辑的函数
editor(rr);
}function editor(rr) {
如果我双击的是“借方BalanceDirection ”,则“借方余额BorrowBalance”可编辑;贷方一样
if (row.BalanceDirection == "借方") {
借方余额可编辑
触发的操作应该怎样写???如何进行控制余额是否可编辑
} else{
贷方余额可编辑
}
}
你这用了什么jquery插件呀,没用过
你可以装firefox,然后装个firebug插件,看生成的html是什么
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>jQuery EasyUI</title>
<link rel="stylesheet" type="text/css" href="../themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="../themes/icon.css">
<script type="text/javascript" src="../jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="../jquery.easyui.min.js"></script>
<script>
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;
}
$(function(){
var lastIndex;
$('#tt').datagrid({
url:'datagrid_data2.json',
toolbar:[{
text:'append',
iconCls:'icon-add',
handler:function(){
$('#tt').datagrid('endEdit', lastIndex);
$('#tt').datagrid('appendRow',{
itemid:'',
productid:'',
listprice:'',
unitprice:'',
attr1:'',
status:'P'
});
var lastIndex = $('#tt').datagrid('getRows').length-1;
$('#tt').datagrid('beginEdit', lastIndex);
}
},'-',{
text:'delete',
iconCls:'icon-remove',
handler:function(){
var row = $('#tt').datagrid('getSelected');
if (row){
var index = $('#tt').datagrid('getRowIndex', row);
$('#tt').datagrid('deleteRow', index);
}
}
},'-',{
text:'accept',
iconCls:'icon-save',
handler:function(){
$('#tt').datagrid('acceptChanges');
}
},'-',{
text:'reject',
iconCls:'icon-undo',
handler:function(){
$('#tt').datagrid('rejectChanges');
}
},'-',{
text:'getChanges',
iconCls:'icon-search',
handler:function(){
var rows = $('#tt').datagrid('getChanges');
alert('changed rows: ' + rows.length + ' lines');
}
}],
onBeforeLoad:function(){
$(this).datagrid('rejectChanges');
},
onClickRow:function(rowIndex){
if (lastIndex != rowIndex){
$('#tt').datagrid('endEdit', lastIndex);
$('#tt').datagrid('beginEdit', rowIndex);
}
lastIndex = rowIndex;
}
});
});
</script>
</head>
<body>
<h1>Editable DataGrid</h1>
<table id="tt" style="width:650px;height:auto"
title="Editable DataGrid" iconCls="icon-edit" singleSelect="true"
idField="itemid" >
<thead>
<tr>
<th field="itemid" width="80">Item ID</th>
<th field="productid" width="100" formatter="productFormatter" editor="{type:'combobox',options:{valueField:'productid',textField:'name',data:products,required:true}}">Product</th>
<th field="listprice" width="80" align="right" editor="{type:'numberbox',options:{precision:1}}">List Price</th>
<th field="unitcost" width="80" align="right" editor="numberbox">Unit Cost</th>
<th field="attr1" width="150" editor="text">Attribute</th>
<th field="status" width="60" align="center" editor="{type:'checkbox',options:{on:'P',off:''}}">Status</th>
</tr>
</thead>
</table>
</body>
</html>
用Column Properties
中的formatter