function _createTable(data){ //对汉字进行转码 $.each(data.data, function(i, obj){ var eventName = unescape(obj.eventName); var levelName = unescape(obj.levelName); obj.eventName = eventName; obj.levelName = levelName; }); //数据处理 var column = [ {title:'ID',field:'id',width:100,align:'left'}, {title:'级别编号',field:'levelNum',width:100,align:'left'}, {title:'级别名称',field:'levelName',width:100,align:'left', formatter:function(data){ if(data == 'null'){ return ""; }else{ return data; } },editor:{type:'text'} }, {title:'活动id',field:'eventId',width:60,align:'left',rowspan:1, hidden:true}, {title:'创建人id',field:'createUid',width:100,align:'left'}, {title:'创建时间',field:'createDate',width:150,align:'left'} ]; var root = listToDataGrid(data); var title = "头像列表"; _getDataGrid("eventListTable", title, 'id', column).datagrid('loadData', root); } function _getDataGrid(id, aTitle, pk, columns){ var el = $('#' + id + ''); if (el.data('datagridInit') !== 'finished'){ var lastIndex; el.datagrid({ columns:[columns], title:aTitle, width:1000, nowrap: false, idField:pk, rownumbers:true, striped:true, singleSelect: true, collapsible:true, sortName: 'levelNum', pagination:false, pageSize: pageSize, sortOrder: 'asc', remoteSort: false, idField:'id', rownumbers:true, toolbar:[{ id:'btnmodify', text:'修改', iconCls:'icon-cut', handler:_showDialog(id) },'-',{ id:'btnremove', text:'删除', iconCls:'icon-cancel', handler:_removeEvent(id) }], onDblClickCell:function(rowIndex, field, value){ lastIndex=rowIndex; $('#'+id).datagrid('endEdit',rowIndex); $('#'+id).datagrid('beginEdit',rowIndex); var oldordering = value; $("input.datagrid-editable-input").val(oldordering).bind("blur",function(evt){ debugger; var dataArry = $('#'+id).datagrid('getSelections'); eventPlayer.setLevelName($(this).val(), dataArry[0].id); $('#'+id).datagrid('endEdit',lastIndex); }).bind("keypress",function(evt){ if(evt.keyCode==13){ debugger; var dataArry = $('#'+id).datagrid('getSelections'); eventPlayer.setLevelName($(this).val(), dataArry[0].id); $('#'+id).datagrid('endEdit',lastIndex); } }).focus(); lastIndex=rowIndex; } }); //注册分页查询方法 var p = $('#' + id).datagrid('getPager'); $pagination(p, { onSelectPage: function(pageNumber, pageSize1){ getEventPlayerDataList(); } }); el.data('datagridInit', 'finished'); }
以上所述是小编给大家介绍的jQuery Easyui DataGrid点击某个单元格即进入编辑状态焦点移开后保存数据,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!
您可能感兴趣的文章: