easyui datagrid 从后台加载过来数据筛选进行前台展示


//定义两个常量

var count = 0;
 var data;

为两个筛选条件的radio 按钮绑定单击事件

  //查看未审核合同
            function checkUnReview(obj) {
                $("#btabsDiv").find("input[type=radio]").not(obj).attr("checked", false);//使div下的radio只能单个被选中
                count++;
                if (count == 1) {
                    data = $("#maingrid").datagrid("getData");
                }
                $("#maingrid").datagrid("loadData", loadFilter(data, "待审核"));
            }
            //查看已审核合同
            function checkReview(obj) {
                count++;
                $("#btabsDiv").find("input[type=radio]").not(obj).attr("checked", false);
                //$("#maingrid").datagrid('reload');
                if (count == 1) {
                    data = $("#maingrid").datagrid("getData");
                }

                $("#maingrid").datagrid("loadData", loadFilter(data, "已审核"));//重新加载数据
            }
            function loadFilter(data, status) {//重新组织datagrid数据,把符合条件的内容加到定义的json字符串中。
                var value = {
                    total: data.total,
                    rows: []
                };
                var x = 0;
                for (var i = 0; i < data.rows.length; i++) {
                    if (data.rows[i].status2 == status) {
                        value.rows[x++] = data.rows[i];
                    }
                }
                return value;
            }

在data-options中添加onLoadSuccess事件,在数据加载成功时触发。用于默认加载符合某个条件的数据

<table id="maingrid" class="easyui-datagrid  tab01" title="" style="width: 100%;height: 100%" data-options="rownumbers:true,nowrap:true,striped:true,remoteSort:true,sortName:'createdate',sortOrder:'desc',singleSelect:true,pagination:true,method:'get',url: '/ashx/Contract/reviewContractData.ashx?module=reviewServiceContract', toolbar:'#tb',onLoadSuccess:function(data1){
                count++;
                if(count==1)
                {
                 data = $('#maingrid').datagrid('getData');
                 $('#maingrid').datagrid('loadData', loadFilter(data, '待审核'));
                }
                }">
                <thead>
                    <tr>
                         <th data-options="field:'ck',checkbox:true"></th>
                            <th data-options="field:'isFrame',align:'center',width:'100px' ">
                            是否为框架合同
                        </th>
                          <th data-options="field:'createmanname',align:'center',width:'100px' ">
                            创建人
                        </th>
                        <th data-options="field:'createdate',align:'center',width:'100px'">
                            创建日期
                        </th>
                            <th data-options="field:'reviewtime',width:'120px'">
                            审批时间
                        </th>
                            <th data-options="field:'status2',width:'100px' ">
                            审核状态
                        </th>
                           <th data-options="field:'status',width:'120px'">
                            状态
                        </th>
                        <th data-options="field:'contractNo',sortable:'true',width:'150px'  ">
                            合同编号
                         </th>
                          <th data-options="field:'isFrame',width:'100px' ">
                            是否为框架合同  
                        </th>
                         <th data-options="field:'buyer',align:'left',width:'200px' ">
                            甲方(买方)  
                        </th>
                         <th data-options="field:'seller',align:'left',width:'200px' ">
                            乙方(卖方)
                         </th>
                             <th data-options="field:'partyC',align:'left',width:'200px' ">
                         丙方
                         </th>
                              <th data-options="field:'partyD',align:'left',width:'200px' ">
                           丁方
                         </th>
                        <th data-options="field:'signedTime',width:'100px' ">
                            签订时间
                        </th>
                        <th data-options="field:'signedPlace',align:'center',width:'100px' ">
                            签订地点
                        </th>
                           <th data-options="field:'validity',align:'center',width:'100px' ">
                            合同有效期
                        </th>
                    </tr>
                </thead>
                  
            </table>

      <input type="radio" name="unReviewRadio" value="" οnclick="checkUnReview(this)" />未审核
       <input type="radio" name="ReviewRadio" value="" οnclick="checkReview(this)"/>已审核

转载于:https://www.cnblogs.com/lbja2/p/6474212.html

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值