您的位置:首页 > 产品设计 > UI/UE

easyui 数据行同步修改---setTimeout延迟避免出错

2017-07-23 21:28 204 查看
我在datagrid中某一列添加了一个timespinner 编辑器,打算修改spinner的时候,datagrid的另一列同步修改。

<table id="dg" class="easyui-datagrid" title=" " style="width:100%;height:auto;"  >
<thead>
<tr>
<th data-options="field:'product_name',width:120">序号</th>
<th  data-options="field:'time_start',width:170 ">开始时间</th>
<th  data-options="field:'time_end',width:170">结束时间</th>
<th data-options="field:'time_diff',width:120,editor:{type:'timespinner',options:{required: false,showSeconds:true,highlight:1,

onSpinUp:function(){

var new_value = $(this).context.value;
planset.spinChange(new_value);
},
}}"  >调整时间</th>

<th data-options="field:'plan_name',width:150 ">计划组</th>

</tr>
</thead>
</table>


发现会出错,后来修正后的代码 

planset.spinChange =function(newValue){

var drow = $("#dg").datagrid("getSelected");
var row_index = $("#dg").datagrid("getRowIndex",drow);
if(!drow)return false;
drow.time_end = seagull.timespinner_add(drow.time_start,newValue).timespinner;
$('#dg').datagrid('updateRow',{
index:row_index,
row:drow,
});
$('#dg').datagrid('unselectRow',row_index);  //必须要取消选择当前行
setTimeout(function(){
$('#dg').datagrid('acceptChanges'); //才能确认修改
$('#dg').datagrid('selectRow', row_index) .datagrid('beginEdit', row_index); //再回到当前编辑器

},10);

}


效果如附件
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: