5 Star 2 Fork 1

lhtzbj12 / bootstrap-table-maintainColSwitch.js

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

bootstrap-table-maintainColSwitch.js

扩展bootstrap-table插件。原插件设置显示/隐藏列时只是临时的,也有cookie插件保存设置,但不方便保存到服务器,本插件就是对其进行扩展,默认保存至cookie,提供事件和参数可以将设置保存至服务器。。

依赖

  • bootstrap-table.js(在此感谢作者为大家奉献这么优秀的插件bootstrap-table.js)
  • jquery.cookie.min.js

使用方法

使用bootstrap-table插件的bootstrapTable方法进行初始化时,传参数maintainColSwitch:true即可开启保存到cookie的功能。

  $('#dataGrid').bootstrapTable({
          url: 'demo.response.json',
          method: 'get',
          sidePagination: 'client', //服务器端用 server
          idField: 'id',
          queryParamsType: '',
          queryParams: '',
          pagination: true,
          showColumns: true,        //启用 设置显示/隐藏 功能按
          maintainColSwitch:true,  //保持显示隐藏列参数,使用默认参数传入 true 即可
          columns: [{
              field: 'state',
              checkbox: true,
          },{
              field: 'id',
              title:'id',
          },{
              field: 'name',
              title:'name',
          },{
              field: 'price',
              title:'price',
          }]
   });

可以传入更多参数

   $('#dataGrid1').bootstrapTable({
           url: 'demo.response.json',
           method: 'get',
           sidePagination: 'client', //服务器端用 server
           idField: 'id',
           queryParamsType: '',
           queryParams: '',
           pagination: true,
           showColumns: true,
           maintainColSwitch:{
               cookieKey:'this.table.columns.maintainCol_dataGrid1',//自定义保存进cookie时的key
               cookieExpires:1,             //自定义过期时间
               onLoad: function () {        //加载时激发
                   console.log('加载成功'); //columns值为数组如: ['id','name','price']
               },
               onSave: function (columns) { //保存时激发,可以在这里将结果保存到服务器端
                   console.log(columns);
               },
               initShowColumns:[],          //如果是从服务端获取设置,则将服务端值填到这里,这里不为空时将不从cookie获取数据
                                            //值为数组,如:['id','name','price']
           },
           columns: [{
               field: 'state',
               checkbox: true,
           },{
               field: 'id',
               title:'id',
           },{
               field: 'name',
               title:'name',
           },{
               field: 'price',
               title:'price',
           }]
       });
The MIT License (MIT) Copyright (c) 2017 lhtzbj12 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

扩展bootstrap-table插件。原插件设置显示/隐藏列时只是临时的,也有cookie插件保存设置,但不方便保存到服务器,本插件就是对其进行扩展,默认保存至cookie,提供事件和参数可以将设置保存至服务器。 展开 收起
JavaScript
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
JavaScript
1
https://gitee.com/lhtzbj12/bootstrap-table-maintainColSwitch.js.git
git@gitee.com:lhtzbj12/bootstrap-table-maintainColSwitch.js.git
lhtzbj12
bootstrap-table-maintainColSwitch.js
bootstrap-table-maintainColSwitch.js
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891