• js 排序


    html代码:

    <th class="sork" id="totalSork" onclick="clickSork(0, $(this))">当日接入数据总量&nbsp;<img src="~/Images/descending.png" style="25px;" /></th>
    <th class="sork" id="overSork" onclick="clickSork(2, $(this))">当日超限数据量&nbsp;<img src="~/Images/descending.png" style="25px;" /></th>
    <th class="sork" id="timeSork" onclick="clickSork(4, $(this))">上一次接入数据时间&nbsp;<img src="~/Images/descending.png" style="25px;" /></th>

    js代码:

    给你所要排序的字段赋值:

    var total = [], acTime = [], over = [],dataSork = 0function chart(){//赋值方法
    
    $.ajax({
    
    url: "/aa/QueryData",
    data: {
    pageIndex: pageIndex,
    sork: dataSork//排序参数
    },
    type: "POST",
    dataType: "JSON",
    beforeSend: function () {
    layer.load(1, {
    offset: ['50%', "50%"], shade: false
    });
    },
    success: function (data) {
    
     showloading(false);
    
      total = [], acTime = [], over = [];
    
    if (data.infoList.length > 0) {
    for (var i = 0; i < data.infoList.length; i++) {
    
    total.push(data.infoList[i].totalCarNum);
    over.push(data.infoList[i].overCarNum);
    acTime.push(data.infoList[i].dcAcceptTime);
    
    }
    
    }
    
    }
    
    })
    
    }
    
    排序方法:
    
     List<OverCaseData> listdata = new List<OverCaseData>();
    
    //排序
    function clickSork(val, e) {
    if (!isSork) {
    isSork = true;
    if (e.children()[0].src.indexOf('descending_pitch') > 0) {
    e.children()[0].src = "../Images/ascending_pitch.png";
    dataSork = val + 1;
    }
    else if (e.children()[0].src.indexOf('descending') > 0) {
    e.children()[0].src = "../Images/descending_pitch.png";
    dataSork = val;
    }
    else {
    e.children()[0].src = "../Images/descending_pitch.png";
    dataSork = val;
    }
    var sork = document.getElementsByClassName("sork");
    for (var i = 0; i < sork.length; i++) {
    if (sork[i].id != e[0].id) {
    sork[i].children[0].src = "../Images/descending.png";
    }
    }
    chart(0, 1);//刷新
    }
    else {
    layer.msg('请稍后再试...');
    }
    }

    后台代码:

    switch (param.Sork)
    {
    case 1://过车总数升序
    listdata = dataList.OrderBy(v => v.totalCarNum).ToList();
    break;
    case 2://超限总数升序
    listdata = dataList.OrderBy(v => v.overCarNum).ToList();
    break;
    case 3://超限总数降序
    listdata = dataList.OrderByDescending(v => v.overCarNum).ToList();
    break;
    case 4://接收时间升序
    listdata = dataList.OrderBy(v => v.dcAcceptTime).ToList();
    break;
    case 5://接收时间降序
    listdata = dataList.OrderByDescending(v => v.dcAcceptTime).ToList();
    break;
    default:
    listdata = dataList.OrderByDescending(v => v.totalCarNum).ThenByDescending(v => v.overCarNum).ThenByDescending(v => v.dcAcceptTime).ThenByDescending(v => v.timeState).ThenByDescending(v => v.onLineTime).ThenByDescending(v => v.offLineTime).ToList();
    break;
    }
  • 相关阅读:
    浅析AI人脸识别/车辆识别智能分析网关的深度学习算法及应用场景
    浅析基于AI智能识别技术的明厨亮灶智能化监管方案
    AI人脸识别/车辆识别智能分析网关微信端告警消息推送的开发流程
    AI车辆检测/人脸检测智能分析网关新增烟火检测识别与烟火告警
    状态压缩1815. 得到新鲜甜甜圈的最多组数
    数位DP2出现的次数
    状态压缩解题技巧
    数位DP6151. 统计特殊整数
    数位DP600. 不含连续1的非负整数
    状态压缩1755. 最接近目标值的子序列和
  • 原文地址:https://www.cnblogs.com/codehistory/p/11262675.html
Copyright © 2020-2023  润新知