- $("#tt").datagrid({
- title: '批次',
- url: '',
- method: 'get',
- idfield: '宿舍号',
- pagination: false,
- iconCls: 'icon-save',
- rownumbers: true,
- pageSize: 10000,
- pageList: [15, 30],
- toolbar: '#tb',
- striped: true,
- fitcolumns: true,
- //nowarp: false,
- singleSelect: true,
- columns: [[
- {
- title: '年度',
- field: '年度',
- width: 60,
- editor: {
- type: 'combobox',
- options: {
- required: true,
- missingMessage: 'ccccc',
- multiple: false,
- editable: false,
- valueField: 'VALUE',
- textField: '年度',
- url: '../ComService.ashx/ProcessRequest?method=GetYearComboData'
- }
- }
- },
- {
- title: '培养层次',
- field: '培养层次',
- width: 80,
- editor: {
- type: 'combobox',
- options: {
- required: true,
- missingMessage: '请选择培养层次',
- multiple: false,
- editable: false,
- valueField: 'id',
- textField: 'text',
- data: [{ 'id': '本科生', 'text': '本科生' }, { 'id': '研究生', 'text': '研究生'}]
- }
- }
- },
- {
- title: '就学地',
- field: '就学地',
- width: 80,
- editor: {
- type: 'combobox',
- options: {
- required: true,
- missingMessage: '请选择就学地',
- multiple: false,
- editable: false,
- valueField: 'id',
- textField: 'text',
- data: [{ 'id': '本部', 'text': '本部' }, { 'id': '暨阳', 'text': '暨阳'}]
- }
- }
- },
- {
- title: '批次名称',
- field: '批次名称',
- width: 150
- },
- {
- title: '修改',
- field: 'edit',
- width: 60,
- formatter: function (value, row, index) {
- if (row.editing) {
- var editLink = '<input type="button" value="保存" οnclick="doSave(' + index + ')">';
- return editLink;
- } else {
- var editLink = '<input type="button" value="修改" οnclick="doEdit(' + index + ')">';
- return editLink;
- }
- }
- },
- {
- title: '删除',
- field: 'del',
- width: 60,
- formatter: function (value, row, index) {
- if (row.editing) {
- var editLink = '<input type="button" value="取消" οnclick="doCancel(' + index + ')">';
- return editLink;
- } else {
- var delLink = '<input type="button" value="删除" οnclick="doDelete(\'' + row['批次名称'] + '\')">';
- return delLink;
- }
- }
- }
- ]],
- onAfterEdit: function (rowIndex, rowData, changes) {
- //endEdit该方法触发此事件
- alert(changes);
- editRow = undefined;
- },
- onBeforeEdit: function (index, row) {
- row.editing = true;
- $('#tt').datagrid('refreshRow', index);
- },
- onAfterEdit: function (index, row) {
- row.editing = false;
- $('#tt').datagrid('refreshRow', index);
- },
- onCancelEdit: function (index, row) {
- row.editing = false;
- $('#tt').datagrid('refreshRow', index);
- }
- });
- initTT
- var editRow = undefined;
- function doEdit(index) {
- if (editRow != undefined) {
- $("#tt").datagrid('cancelEdit', editRow);
- editRow = undefined;
- }
- $("#tt").datagrid('selectRow', index);
- var rows = $("#tt").datagrid('getSelections');
- if (rows.length == 1) {
- if (editRow == undefined) {;
- $("#tt").datagrid('beginEdit', index);
- editRow = index;
- }
- }
- }
- function doSave(index) {
- $("#tt").datagrid('endEdit', index);
- editRow = undefined;
- }
- function doCancel(index) {
- $("#tt").datagrid('cancelEdit', index);
- editRow = undefined;
- }
- function doDelete(pcname) {
- if (editRow != undefined) {
- $("#tt").datagrid('cancelEdit', editRow);
- editRow = undefined;
- }
- $.messager.confirm('确认', '你真的要删除该批次名称吗?', function (r) {
- if (r) {
- $.ajax({
- type: "post",
- url: "PiciService.ashx/ProcessRequest?method=Delete" + "&pcmc=" + pcname,
- data: null,
- success: function (result) {
- if (result.Success) {
- $.messager.alert("提示", "删除成功!", "info");
- getAllData();
- }
- else {
- $.messager.alert("错误", result.Msg, "info");
- }
- },
- dataType: "json"
- });
- }
- });
- }