Flexigrid绑定数据后更改符合条件的行的样式

直接写代码,应该有更好的方法。

构造参数的js文件:

var option = {//构造FlexiGrid
    url: "../../Manage/ManagerView/Ashx/srxfhz.ashx",
    KeyboardSelect: true, //允许键盘上下进行选择当前行
    resizable: true, //允许改变表格大小
    dataType: 'json',
    colModel: [
                { display: '消费日期', name: 'bill_comedate', width: 200, sortable: false, align: 'center' },
                { display: '消费金额', name: 'bill_zhje', width: 180, sortable: true, align: 'center' },
                 { display: '开台数量', name: '消费桌数', width: 180, sortable: true, align: 'center' },
                 { display: '消费单数', name: '消费桌数', width: 180, sortable: true, align: 'center' },
                 { display: '消费人次', name: '消费人次', width: 180, sortable: true, align: 'center' }
    striped: true,
    usepager: true,
    title: '折后应收汇总',
    useRp: true,
    rp: 40,
    showTableToggleBtn: false,
    width: 'auto',
    height: 600,
    rpOptions: [10, 15, 20, 25, 40, 50], //可选择设定的每页结果数
     procmsg: '请等待数据正在加载中 …', 
    pagestat: '显示从{from}到{to}条数据,共有{total}条数据',    
    resizable: false, 
    sortname: "bill_comedate",
    sortorder: 'DESC',
    onSubmit: function() {//获取数据时执行
        AjaxMessageSwitch(true);
        return true;
    },
    onEnd: function() {//获取数据结束时执行
        AjaxMessageSwitch(false);
        var tr = $("#customers").find("tr");
        $(tr).each(function() {
         //找到含有总计的那一行添加样式       
            if ($(this).find('td').find('div').text().indexOf('总计') >= 0) {
                $(this).find('td').find('div').css("color", "red").css("font-weight", "bold");                
                return false;
            }
        });
    },
    InputDataJson: function() {
      return { TextKey: $("#Key").val() };
    },
    onAllowKeyboardSelect: function() {
        if (document.activeElement.id == "Key") {
            return false;
        }
        return true;
    }
};


前台ASPX页面

    <script type="text/javascript">
        $(document).ready(function(e) {
            $("#customers").flexigrid(option);
        });
    </script>

主要就是在onEnd:里面循环比较,找到符合条件的数据,然后添加样式。

各位有更省事的方法,还忘告知。

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

踏平扶桑

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值