可以隐藏 SlickGrid 列而不将其从“列”中删除。大批?
我想隐藏一列(它的 ID 列对于每行都是唯一的),但我无法从“列”数组中删除它,因为当对行执行操作时我需要行中的数据(选择、排序等)。
例如,排序后,我需要获取将它们与之前的样式相匹配的行,并且我可以使用 ID 列来执行此操作。我需要该行中的数据,我只是不想显示它。
谢谢。
I'd like to hide a column (its an ID column that is unique for each row), but I cannot remove it from the "columns" array because I need that data in the Row when actions are performed on the Row (Selection, Sorting, ect).
After being sorted for example, I need to grab the Rows match them up to the previous styles that they had before, and I can do this with the ID column. I need the data in the row, I just don't want it to be displayed.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
答案是否定的,但这不是您正在寻找的答案:)
除了查看哪些列来获取数据之外,它们与您的数据项之间没有硬链接。您不必拥有可见的列即可在数据项上拥有 ID。
The answer is NO, but that is not the answer you are looking for :)
Other than what columns are looking at to grab their data, there is no hard link between them and what your data items look like. You don't have to have a column visible to have an ID on your data item.
如果有人仍在寻找这个,我找到了一种方法......它不是很优雅,但确实有效。正如 Simon 建议的那样,将 Id 列添加为网格中的最后一个。将 cssClass 和 headerCssClass 设置为“display:none !important”,并将 width、minWidth 和 maxWidth 列选项设置为 0,如下所示:
css 为:
.reallyHidden { display: none !important;}
希望有所帮助。
In case anyone is still looking for this, I've found a way... it's not massively elegant but it does work. As Simon, suggested, add the Id column as the last in the grid. Set both the cssClass and headerCssClass to be "display:none !important" and set the width, minWidth and maxWidth column options to 0 as follows:
and the css is:
.reallyHidden { display: none !important;}
Hope that helps.
这是不可能的,但作为解决方法,您可以将 width/maxWidth 设置为 1,将名称设置为空字符串,并将该列放置在所有其他列的最右侧。像这样(示例在coffeescript中,如果您不确定语法,请使用http://js2coffee.org/):
It is not possible BUT as a workaround you can set the width/maxWidth to 1, set the name to an empty string and place the column at the far right of all other columns. Like so (example is in coffeescript, if you feel uncertain about the syntax use http://js2coffee.org/):
我今天遇到了同样的问题,我正在处理纯数组数据。如果您在数据数组的末尾添加值,但不在列数组中定义它们,则数据会存在并且您可以在事件中使用它,但不会显示。
示例:
正如您在代码中看到的,我向网格提供了第四个值,没有列定义。
I had the same problem today, and i am working with pure array data. if you add your values at the end of the data array, but do not define them in the columns-array, the data is present and you can use it in your events, but it is not shown.
example:
As you can see in the code, i provided a 4th value to the grid with no column-definition.
对于此类问题,我使用了两个数组。一种用于显示,另一种用于columnPicker。这是如何,
For this kind of problem, I've used two arrays. One for showing and the other one for columnPicker. Here is how,
在 coloumns.push({id:id,name:name,Hidden:true})
//hidden 确保在绑定网格时删除该列
in coloumns.push({id:id,name:name,Hidden:true})
//hidden ensures that the column is removed while binding grid
我意识到这是一个老问题,但正确的方法是使用 dataProvider 并利用 getItemMetaData 来提供您不一定希望显示的信息。
当您选择行时,您可以调用 grid.getItemMetaData(cell.row) 来获取您需要的额外信息。 getItemMetaData 预计返回一个描述行级和单元格级元数据的 jsonObject。
这是描述它的文档。
https://github.com/mleibman/SlickGrid/wiki/向网格提供数据
I realize this is an old question but the correct way to do this is by using a dataProvider and utilizing getItemMetaData to provide information you don't necessarily want displayed.
When you select your row you can call grid.getItemMetaData(cell.row) to get the extra information you need. getItemMetaData is expected to return a jsonObject describing both row and cell level metaData.
Here's the docs that describe it.
https://github.com/mleibman/SlickGrid/wiki/Providing-data-to-the-grid
在寻找有关这个问题的一些答案后,我找到了一种解决方法,可以完全隐藏列并仍然保存数据。
我最初的问题是我需要隐藏网格的 ID 列,所以基本上我通过创建唯一具有 name 属性的列来隐藏 ID 列,而不指定其他任何内容,然后创建了我期望的列。
After looking for some answers about this questions I've found a workaround that quite does the trick of hiding the column and still save the data.
My initial problem was that I needed to hide the ID column of the grid, so basically I hid the ID column by creating the only with the name attribute without specifying anything else and the column was then created I was expecting.