【前端开发-EasyUI】DataGrid总结

1.表格加载接口返回的指定对象数据

关键点:loadFilter对返回的数据data进行过滤
var dataGridUrl = $CONFIG.base_url+'/api/report/purchase/type/new?officeId='+$('#belong-project').combotree('getValue');

// 定义表格
var conf = {
    options:{
        pagination:true,
        idField:'id',
        rownumbers: false,
        singleSelect:true,
        url:dataGridUrl,
        method:'get',
        loadFilter: function(data){
           if (data){
               return data.result.details;
           }
        },
        rowStyler: function(index,row){
            return {class:'double-row'};
        },
        columns: [[
            {field:'belongOfficeName',title:'项目名称',width:'10%',align:'center'
            },
            {field:'materialType',title:'材料类别',width:'10%',align:'center'
            },
            {field:'purchaseFee',title:'采购金额(不含税)',width:'15%',align:'center',
                formatter:function (value, row, index) {
                    return row.tenderFee+row.bidFee+row.supplyFee+row.processFee+row.sporadicFee+row.emergencyFee+row.otherFee;
                }
            },
            {field:'tenderFee',title:'招标采购金额',width:'10%',align:'center'
            },
            {field:'bidFee',title:'询价采购金额',width:'10%',align:'center'
            },
            {field:'supplyFee',title:'甲供金额',width:'10%',align:'center'
            },
            {field:'processFee',title:'自加工金额',width:'10%',align:'center'
            },
            {field:'sporadicFee',title:'零星采购',width:'8%',align:'center'
            },
            {field:'emergencyFee',title:'应急采购',width:'8%',align:'center'
            },
            {field:'otherFee',title:'其他方式采购',width:'10%',align:'center'
            },
        ]],
        onLoadSuccess:function (data) {
            $('#btn-search').linkbutton('enable');
            $('#btn-search').linkbutton({'text':'搜索'});
        },
        onLoadSuccess:function (index) {

            if(index.rows){
                for(let i=0;i<index.total;i++){
                    $('#tt').datagrid('beginEdit',i);
                }
            }
        },
    },
};
var dg = $('#tt').datagrid('subgrid', conf);

2.datagrid单独加载指定接口的参数

exports.loadList =loadfunction(){
     var params = {
            beginDate:beginDate,
            endDate:endDate,
            officeId:$('#belong-project').combotree('getValue'),
            no:$('#report-no').textbox('getValue'),
        };
        $('#tt').datagrid({
            url: '/api/report/issue/check/list',
            queryParams:params,
        });
}

3.清空datagrid数据

  $('#form-tt').datagrid({data:{rows:[]}});

4.获取datagrid标签名和键名(用于导出)

  var colKeys = $('#tt').datagrid('getColumnFields')
        var colNames=[];
        for(var i=0;i<colKeys.length;i++)
        {
            var col = $('#tt').datagrid( "getColumnOption" , colKeys[i] );
            colNames.push(col.title);
        }

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值