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事件,在数据加载成功时触发。用于默认加载符合某个条件的数据


               
                   
                        
                           
                         
                       
                           
                           
                          
                       
                         
                        
                        
                            
                             
                       
                       
                          
                   
               
                  
           

                            是否为框架合同
                       

                            创建人
                       

                            创建日期
                       

                            审批时间
                       

                            审核状态
                       

                            状态
                       

                            合同编号
                        

                            是否为框架合同  
                       

                            甲方(买方)  
                       

                            乙方(卖方)
                        

                         丙方
                        

                           丁方
                        

                            签订时间
                       

                            签订地点
                       

                            合同有效期
                       

      未审核
       已审核

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

你可能感兴趣的:(easyui datagrid 从后台加载过来数据筛选进行前台展示)