zoukankan      html  css  js  c++  java
  • bootstrap table 保留翻页选中数据

    $(function () {
      $('#exampleTable').on('uncheck.bs.table check.bs.table check-all.bs.table uncheck-all.bs.table',function(e,rows){
    var datas = $.isArray(rows) ? rows : [rows]; // 点击时获取选中的行或取消选中的行
    examine(e.type,datas); // 保存到全局 Array() 里
    });
    })
    //exampleTable为bootstrap table名称
    var overAllIds = new Array();  //全局数组
    function examine(type,datas){
    if(type.indexOf('uncheck')==-1){
    $.each(datas,function(i,v){
    // 添加时,判断一行或多行的 id 是否已经在数组里 不存则添加 
    overAllIds.indexOf(v.id) == -1 ? overAllIds.push(v.id) : -1;
    });
    }else{
    $.each(datas,function(i,v){
    overAllIds.splice(overAllIds.indexOf(v.id),1); //删除取消选中行
    });
    }
    }
    //设置bootstrap table checkbox自动选中
    columns : [
    {
    checkbox : true,
    formatter : function(value, row, index) {
    if (row.userId == $("#userId").val()) {
    overAllIds.indexOf(row.id) == -1 ? overAllIds.push(row.id) : -1;
    return {
    checked: true//设置选中
    };
    }
    }
    },
      {
    title : '操作',
    width : '130',//设置列宽
    field : 'id',
    align : 'center'
      }
    ]
  • 相关阅读:
    Codeforces Round #281 (Div. 2) A. Vasya and Football(模拟)
    自动生成代码工具
    导入导出维护计划
    收集错误日志方法
    C#常用控件和属性
    人民币转换
    身份证验证
    设置下拉列表项的默认值
    清除维护任务
    清除MSSQL历史记录
  • 原文地址:https://www.cnblogs.com/liw66/p/10188942.html
Copyright © 2011-2022 走看看