一、点击单元格更新数据
table.on('tool(tbEvent)', function(obj) {
var data = obj.data,layEvent = obj.event;
var $this = $(this);
layer.open({
title: '设置状态', type: 1,shade: false,
maxmin: true, shade: 0.5,anim: 1,skin: 'layer-ext-myskin',
area: ['650px', '200px'],content:$('#checkDiv'),
btn:['保存','取消'],
yes: function(index){
//后台操作方法
$this.text('');//点击的单元格赋值
//给该行指定列赋值
var rowindex = obj.tr[0].rowIndex;//点击行
var tr = $('tr[data-index=\''+rowindex +'\']');
tr.find('td[data-field = \'VC_CHUQIN\']').html('<div class="layui-table-cell">'+新值+'</div>');
//tr.find('td[data-field = \'VC_CHUQIN\']').css('color','red');//改变颜色
}
});
});
二、点击单元格修改整列数据
table.on('tool(tbEvent)', function(obj) {
var data = obj.data,layEvent = obj.event;
var $this = $(this);
layer.open({
title: '设置状态', type: 1,shade: false,
maxmin: true, shade: 0.5,anim: 1,skin: 'layer-ext-myskin',
area: ['650px', '200px'],content:$('#checkDiv'),
btn:['保存','取消'],
yes: function(index){
//后台操作方法
var cellIndex = $this[0].cellIndex;
if(parseInt(cellIndex,10) < 10) cellIndex = '0'+cellIndex;
var n = 'td[lay-event=\''+cellIndex+'\']'; //td中lay-event相同的
$(n).html('<div class="layui-table-cell">要赋的值</div>');
//$this.text('');//点击的单元格赋值
//以上是刷新点击框,下面刷新指定列
$.ajax({
url: basePath + '/findData.do?orgId=',
type: 'post', async: false, dataType: 'json',
success: function (result) {
var newshuju = result.data;
for(var b=0;b<=newshuju.length;b++){
var v = newshuju[b];
var tr = $('tr[data-index=\''+b+'\']');
tr.find('td[data-field = \'VC_CHUQIN\']')
.html('<div class="layui-table-cell">'+v.VC_CHUQIN+'</div>');
//tr.find('td[data-field = \'VC_CHUQIN\']').css('color','red');
}
}
});
}
});
});