javascript - 将复选框值存储在 webix 的 cookie 中

标签 javascript cookies store webix

我正在使用 webix 显示具有特定列的数据表。我为每个列创建了一个复选框来显示/隐藏列。我需要将此复选框值存储在 cookie 中,以便当客户端刷新页面时,选中的复选框保持选中/未选中状态。我怎样才能做到这一点?

这是我的代码:

                    {

                       view: "toolbar",

                        cols: [
                            { view: "checkbox", id: "test1", label: "test1", value:1 },    
                            { view: "checkbox", id: "test2", label: "test2", value: 1 },    
                            { view: "checkbox", id: "test3", label: "test3", value: 1 },    
                            { view: "checkbox", id: "test4", label: "test4", value:1 }
                        ]

                    },
                    {
                        view: "datatable",
                        id:   "table",
                        columns: [
                            { id: "test1", header: ["test1"] },
                            { id: "test2", header: ["test2"] },
                            { id: "test3", header: ["test3"] },
                            { id: "test4", header: ["test4"] },
                        ],
                     }

最佳答案

使用 webix.storage.local.put() 和 webix.storage.local.get() 函数解决了这个问题。我在复选框上附加了 onChange 事件,并使用 setValues 保存了当前的复选框设置。

关于javascript - 将复选框值存储在 webix 的 cookie 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33120197/

相关文章:

用于在 html 中传递当前日期的 Javascript ClassName

javascript - Angular UI 路由器 - 具有命名模板最佳实践的抽象状态

javascript - 填空和多项选择测验

JavaScript 迭代事件处理程序/监听器

cookies - 带有 chrome 扩展的 cookie 或 localStorage

javascript - 当 cookie 存在时隐藏 div 元素

javascript - 如何根据路由参数从众多用户中只导入一个用户?

http - 处理 HTTP cookie 以模拟类似浏览器的行为

swift - 如何存储使用委托(delegate)方法发回的数据?

php - mysql 存储用户代理、推荐等的最有效方式