关闭

点击单元格进入编辑状态

78人阅读 评论(0) 收藏 举报
$(function(){
$('#HyqPeopledatagrid').datagrid({
//title:'人员',
url:'people/people.do',
queryParams: form2Json("peoplesearchform"),
singleSelect: true,
fitColumns:true,
onClickCell: onClickCell,
columns:[[{
field:'checkbox',
title:'多选框',
checkbox:true,
width:10,
hidden:true
},{
field:'id',
title:'ID',
width:10,
sortable:true,
hidden:true
},{
field:'name',
title:'姓名',
width:20,
sortable:true
},{
field:'sex',
title:'性别',
width:10,
sortable:true,
hidden:false
},{
field:'idcard',
title:'身份证号',
width:30,
sortable:true,
hidden:false
},{
field:'phone',
title:'手机号',
width:20,
sortable:true,
hidden:false
},{
field:'gangwei',
title:'报考岗位',
sortable:true,
hidden:false,
width:90,
formatter: function(value,row,index){
if(row.gangwei!=null)
value = row.gangwei.id+"|"+row.gangwei.zpdw+","+row.gangwei.gwmc;
else
value=" ";
return value;
}
},{
field:'school',
title:'毕业院校',
width:30,
sortable:true,
hidden:true
},{
field:'professional',
title:'专业',
width:30,
sortable:true,
hidden:true
},{
field:'workplace',
title:'工作单位',
width:30,
sortable:true,
hidden:true
},{
field:'workyears',
title:'工作年限',
width:15,
sortable:true,
hidden:true
},{
field:'lastacademy',
title:'学历',
width:20,
sortable:true,
hidden:false
},{
field:'degreename',
title:'学位',
width:20,
sortable:true,
hidden:true
},{
field:'checkstatus',
title:'审核状态',
sortable:true,
width:20,
hidden:true,
formatter: function(value,index){
if(value == 0){
value='<span style="font-weight:bold">待审核</span>';
}else if(value == 1){
value='<span style="color:green">通过</span>';
} else {
value = '<span style="color:red">未通过</span>';
};
return value;
}
},{
field:'checknum',
title:'审核次数',
sortable:true,
align:'center',
hidden:true
},{
field:'ispay',
title:'交费状态',
sortable:true,
align:'center',
hidden:true,
formatter: function(value,index){
if(value == 0){
value='<span style="font-weight:bold">未交费</span>';
} else if(value == 1){
value='<span style="color:green">已交费</span>';
} else if(value == 2){
value = '<span style="color:blue">贫困生</span>';
} else {
value = '<span style="color:red">已退费</span>';
}
return value;
}
},{
field:'belonguser',
title:'录入账号',
sortable:true,
align:'center',
},{
field:'dingdanno',
title:'报名序号',
sortable:true,
align:'center',
},{
field:'searchno',
title:'查询序号',
sortable:true,
align:'center',
editor : {
type: 'validatebox',options:{required:true}
           }
},{
field:'createtime',
title:'创建时间',
sortable:true,
align:'center',
hidden:false,
},{
field:'updatetime',
title:'更新时间',
sortable:true,
align:'center',
hidden:true,
}]],
/*onClickRow:function(index,row){//运用单击事件实现一行的编辑结束,在该事件触发前会先执行onAfterEdit事件  
    if (lastIndex != index){  
      $('#HyqPeopledatagrid').datagrid('endEdit', lastIndex);
    }  
   },
   onDblClickRow:function(index,row){//运用双击事件实现对一行的编辑  
    if (lastIndex != index){  
      $('#HyqPeopledatagrid').datagrid('endEdit', lastIndex);  
      $('#HyqPeopledatagrid').datagrid('beginEdit', index);  
      lastIndex = index;  
   
   },
    onAfterEdit:function(index,row,changes){  
    var rowId = row.id;  
    $.ajax({  
          url:"people/update.do" ,  
          data: {id:row.id,searchno:row.searchno},  
          success: function(text){
          $('#HyqPeopledatagrid').datagrid('reload');
          if(!text.status)
        $.messager.alert('提示信息',text.info,'');    
          }  
       });
      
   }, */
toolbar:[
{
text:'刷新',
iconcls: 'icon-reload',
handler: function(){
$('#HyqPeopledatagrid').datagrid('load');
}
}
<c:forEach items="${menubuttons}" var="list" varStatus="stat">  
<c:if test="${stat.first}">,'-',</c:if> ${list.mbattribute }<c:if test="${!stat.last}">,</c:if> 
</c:forEach>
],
});
HYQMS.HyqPeople.startCheck = function startCheck(){
if(HYQMS.HyqPeople.selectedData==undefined) {
HYQMS.MSG.alert('请单击要修改数据的行进行选择!');
return false;
}
var id = HYQMS.HyqPeople.selectedData.id;
HYQMS.EUI.newWindow({
title:'审核人员',
height:'640',
width:'800',
href:'people/loadcheck.do',
queryParams:{
id:id,
},
});
};
HYQMS.HyqPeople.startAdd = function startAdd(){
window.open("people/loadadd.do");
};
HYQMS.HyqPeople.startSave = function startSave(){
if(HYQMS.HyqPeople.selectedData==undefined) {
HYQMS.MSG.alert('请单击要修改数据的行进行选择!');
return false;
}
var id = HYQMS.HyqPeople.selectedData.id;
window.open("people/loadupdate.do?id="+id);
};

/*导出Excel*/
HYQMS.HyqPeople.startExport = function startExport(){
window.open('people/exportexcel.do');
};

//判断是否结束编辑
var editIndex = undefined;
   function endEditing(){
    if (editIndex == undefined){return true}
    if ($('#HyqPeopledatagrid').datagrid('validateRow', editIndex)){
    $('#HyqPeopledatagrid').datagrid('endEdit', editIndex);
    if($('#HyqPeopledatagrid').datagrid('getChanges').length>0) {//值有改变就提交数据库
    var row = ($('#HyqPeopledatagrid').datagrid('getSelected'));
        $.ajax({  
              url:"people/update.do" ,  
              data: {id:row.id,searchno:row.searchno},  
              success: function(text){
              $('#HyqPeopledatagrid').datagrid('acceptChanges');
              //$('#HyqPeopledatagrid').datagrid('reload');
              if(!text.status)
            $.messager.alert('提示信息',text.info,'');    
              }  
           });
    }
    editIndex = undefined;
    return true;
    } else {
    return false;
    }
   }
   //单击表格单元格
   function onClickCell(index, field){
    if (endEditing()){
    $('#HyqPeopledatagrid').datagrid('selectRow', index)
    .datagrid('editCell', {index:index,field:field});
    editIndex = index;
    }
   }
   
});
0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:22486次
    • 积分:790
    • 等级:
    • 排名:千里之外
    • 原创:57篇
    • 转载:17篇
    • 译文:0篇
    • 评论:1条