easyui记录

文档:http://www.jeasyui.net/plugins
编辑:

$('#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({
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,
        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',  110, align: 'center', formatter: function (value, row) {
                    return GetBillCategory(value);
                }
            },
            {
                title: '费用类型', field: 'BillType',  110, align: 'center', formatter: function (value, row) {
                    return GetBillType(value);
                }
            },
            { title: '项目', field: 'ProjectName',  160, align: 'center' },
            { title: '部门', field: 'DepartmentName',  110, align: 'center' },
            { title: '项目描述', field: 'ProDescription',  110, align: 'center' },
            { title: '', field: 'BYear',  50, align: 'center' },
            { title: '', field: 'BMonth',  50, align: 'center' },
            {
                title: '金额', field: 'Amount',  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',  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',  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',  100, align: 'center', formatter: function (value, row) {
                    return value ? value.substring(0, value.indexOf('T')) : '';
                }
            },
            { title: '发票号码', field: 'InvoiceNumber',  110, align: 'center' },
            {
                title: '收/付款日期', field: 'ReceivablesDate',  100, align: 'center', formatter: function (value, row) {
                    return value ? value.substring(0, value.indexOf('T')) : '';
                }
            },
            {
                title: '合同账期到账日', field: 'ArrivalDate',  100, align: 'center', formatter: function (value, row) {
                    return value ? value.substring(0, value.indexOf('T')) : '';
                }
            },
            { title: '抬头', field: 'InvoiceIssuingName',  110, align: 'center' },
            { title: '对账负责人', field: 'ChargePersonName',  110, align: 'center' },
            { title: '供应商', field: 'SupplierName',  110, align: 'center' },
            {
                title: '状态', field: 'StatusCode',  120, align: 'center', formatter: function (value, row) {
                    return GetStatusCode(value);
                }
            },
            {
                title: '审批日期', field: 'ApprovalDate',  100, align: 'center', formatter: function (value, row) {
                    return value ? value.substring(0, value.indexOf('T')) : '';
                }
            },
            { title: '备注', field: 'Remark',  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,
         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);
        }
    });

http://www.jeasyui.net/plugins

原文地址:https://www.cnblogs.com/xsj1989/p/12455940.html