文档:http://www.jeasyui.net/plugins
编辑:
$('#obmdlg').find('#IsActiveWave').prop('checked', result.IsActiveWave);//设置checkbox选中
$('#selectInventory').edatagrid({ url: '/Inbound/GetIBDetailToCount', queryParams: pdparas });//pdparas是参数{a:1,b:2}
$('#ezd1').ezdialog({
submitUrl: '/xxx/xxx',
refreshTable: '#applicationview',
ezcontent: [
{ title: 'Id', field: 'Id', hidden: true },
{ title: '账单类型', field: 'BillType', type: 'combobox' },
{ title: '项目', field: 'Project', type: 'combobox' },
{ title: '项目描述', field: 'ProDescription', type: 'textbox' },
{ title: '部门', field: 'Department', type: 'combobox' },
{ title: '年', field: 'BYear', type: 'combobox' },
{ title: '月', field: 'BMonth', type: 'combobox' },
{ title: '金额', field: 'Amount', type: 'textbox' },
{ title: '税率', field: 'TaxRate', type: 'textbox'},
{ title: '税额', field: 'TaxAmount', type: 'textbox'},
{ title: '开票日期', field: 'InvoiceDate', type: 'datebox', formatter: function (value, row) { return value ? value.substr(0, 10) : ''; }},
{ title: '发票号码', field: 'InvoiceNumber', type: 'textbox'},
{ title: '收款日期', field: 'ReceivablesDate', type: 'datebox', formatter: function (value, row) { return value ? value.substr(0, 10) : ''; }},
{ title: '合同账期到帐日', field: 'ArrivalDate', type: 'datebox', formatter: function (value, row) { return value ? value.substr(0, 10) : ''; }},
{ title: '发票抬头', field: 'InvoiceIssuing', type: 'textbox'},
{ title: '对账负责人', field: 'ChargePerson', type: 'textbox' },
{ title: '状态', field: 'StatusCode', type: 'combobox' },
{ title: '备注', field: 'Remark', type: 'textbox' },
{ title: '申请人', field: 'ApplicantName', options: "{readonly: true}" },
{ title: '申请人所属部门', field: 'ApplicantOwnDepartment', options: "{readonly: true}" },
//{ title: '预算年份', field: 'BYear', type: 'combobox', options: "{required: true, textField: 'Value', valueField: 'Id'}" },
//{ title: '预算月份', field: 'BMonth', type: 'combobox', options: "{required: true, textField: 'Value', valueField: 'Id'}" },
{ title: 'PaymentUnitId', field: 'PaymentUnitId', hidden: true },
{ title: '给付单位', field: 'PaymentUnit', type: 'combobox', options: "{required: true, onSelect: function(row){$('#ezd1 #PaymentUnitId').textbox('setValue', row.Id);$('#ezd1 #PaymentAccount').combobox({url: '/ExpenseManager/GetPaymentAccount?selUnitId='+row.Id}).combobox('reload');}, textField: 'Value', valueField: 'Value'}" },
{ title: '给付账号', field: 'PaymentAccount', type: 'combobox', native: true, options: "{required: true, textField: 'Value', valueField: 'Value',onLoadSuccess: function(){var val = $(this).combobox('getData');val.length ? $(this).combobox('select', val[0].Value) : '';}}" },
{ title: '付款种类', field: 'PaymentType', type: 'combobox', options: "{required: true, textField: 'Value', valueField: 'Value'}" },
{ title: '单据及附件页数', field: 'AttachmentPageNum', type: 'numberbox', options: "{required: true}" },
{ title: '申请人备注', field: 'Memo' }
]
});
重置数据:$('#ezd2').ezdialog('resetData');
选中的一行:var row = $('#applicationview').edatagrid('getSelected');
选中的多行:var rows = $('#IBMaster').edatagrid("getSelections");
清除选中状态:$('#IBMaster').edatagrid('clearSelections');
$('#IBMaster').edatagrid('reload');
$('#IBMaster').edatagrid('unselectAll');
$('#IBDetail').edatagrid('loadData', []);
组合选择框:
$('#ezd1 #TaxRate').combobox({
editable: true,
valueField: 'Id',
textField: 'Value',
data: TaxRateData,
onSelect: function (record) {
var rate = record.Id;
var amount = $('#ezd1 #Amount').val();
var ta = rate * amount;
var pta = amount + ta;
$('#ezd1 #TaxAmount').textbox("setValue", ta.toString());
$('#ezd1 #TaxAmountTotal').textbox("setValue", pta.toString());
}
});
组合选择框设置选中项
$('#ezd1 #BYear').combobox('select', new Date().getFullYear());
组合选择框,设置数据源Url,得到的是json集合
$('#Departments').combobox({
width: 100,
editable: true,
valueField: 'Id',
textField: 'Name',
url: '/ExpenseManager/GetDepartments',
onSelect: function (row) {
ob.DepartmentId = row.Id;
}
});
数据网格DataView
$('#applicationview').edatagrid({ url: '/ExpenseManager/GetDatas', idField: 'Id', toolbar: '#tb', loadMsg: '加载中...', singleSelect: false,//可多选 pagination: true,
pageSize: 10,
pageList: [10, 20, 30, 50, 100, 200],
nowrap: false, rowStyler: function (index, row) { if ($.trim(row.RejectReason)) { return row.IsApprovalReject ? 'background-color:red;' : 'background-color:yellow;'; } }, columns: [[ { title: '', field: 'Checked', checkbox: true },//复选框,全选 { title: 'Id', field: 'Id', hidden: true }, { title: '账单类型', field: 'BillCategory', width: 110, align: 'center', formatter: function (value, row) { return GetBillCategory(value); } }, { title: '费用类型', field: 'BillType', width: 110, align: 'center', formatter: function (value, row) { return GetBillType(value); } }, { title: '项目', field: 'ProjectName', width: 160, align: 'center' }, { title: '部门', field: 'DepartmentName', width: 110, align: 'center' }, { title: '项目描述', field: 'ProDescription', width: 110, align: 'center' }, { title: '年', field: 'BYear', width: 50, align: 'center' }, { title: '月', field: 'BMonth', width: 50, align: 'center' }, { title: '金额', field: 'Amount', width: 110, align: 'center', formatter: function (value, row) { if (value != null && value != undefined) { var m = parseFloat(value); var v = (Math.round(m * 100) / 100).toFixed(2); return toThousands(v); } else { return ""; } } }, { title: '税额', field: 'TaxAmount', width: 110, align: 'center', formatter: function (value, row) { if (value != null && value != undefined) { var m = parseFloat(value); var v = (Math.round(m * 100) / 100).toFixed(2); return toThousands(v); } else { return ""; } } }, { title: '价税合计', field: 'TaxAmountTotal', width: 110, align: 'center', formatter: function (value, row) { if (value != null && value != undefined) { var m = parseFloat(value); var v = (Math.round(m * 100) / 100).toFixed(2); return toThousands(v); } else { return ""; } } }, { title: '开票日期', field: 'InvoiceDate', width: 100, align: 'center', formatter: function (value, row) { return value ? value.substring(0, value.indexOf('T')) : ''; } }, { title: '发票号码', field: 'InvoiceNumber', width: 110, align: 'center' }, { title: '收/付款日期', field: 'ReceivablesDate', width: 100, align: 'center', formatter: function (value, row) { return value ? value.substring(0, value.indexOf('T')) : ''; } }, { title: '合同账期到账日', field: 'ArrivalDate', width: 100, align: 'center', formatter: function (value, row) { return value ? value.substring(0, value.indexOf('T')) : ''; } }, { title: '抬头', field: 'InvoiceIssuingName', width: 110, align: 'center' }, { title: '对账负责人', field: 'ChargePersonName', width: 110, align: 'center' }, { title: '供应商', field: 'SupplierName', width: 110, align: 'center' }, { title: '状态', field: 'StatusCode', width: 120, align: 'center', formatter: function (value, row) { return GetStatusCode(value); } }, { title: '审批日期', field: 'ApprovalDate', width: 100, align: 'center', formatter: function (value, row) { return value ? value.substring(0, value.indexOf('T')) : ''; } }, { title: '备注', field: 'Remark', width: 120, align: 'center' } ]], onSelect: function (rowIndex, rowData) { $('#expensedetailview').edatagrid('unselectAll').edatagrid({ url: '/ExpenseManager/GetDetail?billId=' + rowData.Id }); } });
接受数据: "{\"total\": " + ds.Count().ToString()+ ", \"rows\": " + GetJsonData(collection, ds, defaultSortField) + "}"; total是总数据条数,GetJsonData返回的是json数据集合
获得选中的数据行:var rows = $('#applicationview').edatagrid('getSelections');
datagrid的样式控制:在columns中的每个列里都可以加入styler: function (value, row, index) {if (row.IsOk && !value) {return 'background-color:#ffee00;color:red;';}},跟formatter用法一样。
日期控件:
//查询账单-开票日期 $('#InvoiceDateTo').datebox({ buttons: buttons, width: 100, editable: false, onHidePanel: function () {//点击 今天 按钮,没法设置选择的日期值,也就是说没法调用 onSelect 事件,所以只能这么写了 var d = $("#InvoiceDateTo").next().find("input[type='hidden']").val(); if (d) { var t = Date.parse(d); var date = new Date(t); var dtf = moment($('#InvoiceDateFrom').datebox('getValue')); var res = (dtf._isValid && !dtf.isBefore(date)) ? dtf.format('YYYY-MM-DD') : moment(date).format('YYYY-MM-DD'); ob.InvoiceDateTo = res; $('#InvoiceDateTo').datebox('setValue', res); } }, onSelect: function (date) { var dtf = moment($('#InvoiceDateFrom').datebox('getValue')); var res = (dtf._isValid && !dtf.isBefore(date)) ? dtf.format('YYYY-MM-DD') : moment(date).format('YYYY-MM-DD'); ob.InvoiceDateTo = res; $('#InvoiceDateTo').datebox('setValue', res); } });
onSelect: function (index, row) {
invflowIds += row.InvFlowId + ',';
console.log(invflowIds);
},
onUnselect: function (index, row) {
var invflowIdStr1 = row.InvFlowId + ',';
var invflowIdStr2 = ',' + row.InvFlowId + ',';
if (invflowIds.indexOf(invflowIdStr1) == 0) {
invflowIds = invflowIds.substring(invflowIdStr1.length);
}
if (invflowIds.indexOf(invflowIdStr2) > 0) {
invflowIds = invflowIds.replace(invflowIdStr2, ',');
}
console.log(invflowIds);
},
onSelectAll: function (rows) {
for (var m = 0; m < rows.length; m++) {
invflowIds += rows[m].InvFlowId + ',';
}
console.log(invflowIds);
},
onUnselectAll: function (rows) {
invflowIds = '';
console.log(invflowIds);
}