如何以百分比指定光滑网格的宽度?
有人知道如何以百分比设置网格宽度吗?
例如 但页面中网格的宽度超过2000像素。它不会根据页面宽度进行调整。
任何帮助将不胜感激。
谢谢 帕德马纳班
Is anybody knows how to set width of the grid in percentage?
for example
but in the page the width of grid is more than 2000 pixels. It does not get adjusted to page width.
Any help would be appreciated.
Thanks
Padmanabhan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我发现这个问题确实很老了,但是我在尝试弄清楚如何让我的列占据表格的整个宽度时遇到了这个问题。希望有一天它能帮助别人。
我无法弄清楚如何显式设置列宽,但我确实让它隐式工作。
操作方法如下:
首先在列声明中添加 width: 300 (或您想要的任何宽度),
为所有列设置此值,您想要更宽的列放置更大的数字,例如 500,
然后在您的选项声明添加 forceFitColumns: true
通过这样做,我能够让我的表列占用表的剩余空间,并保持我想要的相对于彼此的部分。
i see that this question is really old, but i came across this question while trying to figure out how to get my columns to take up the full width of the table. hopefully it'll help someone someday.
i couldn't figure out how to set the column widths explicitly but i did get it to work implicitly.
here's how to do it:
first in your column declaration add width: 300 (or whatever width you want)
set this for all your columns, the ones you want wider put a bigger number, e.g. 500
then in your options declation add forceFitColumns: true
by doing this i was able to get my table columns to take up the remaining space of the table, and maintain the portions i want relative to each other.
我有一个功能可以调整网格大小。
不要忘记将
forceFitColumns: true
添加到网格选项中,如 conman 上面所述I have a function to do a grid resize.
Don't forget to add
forceFitColumns: true
to your grid options as conman says above仅供参考,这似乎在 SlickGrid 的最新版本中可以开箱即用。 :)
FYI, this appears to work out of the box in recent versions of SlickGrid. :)
是的,这是可能的,但我找不到简单的解决方案。
所以你必须对其进行大量定制。
我目前正在为此研究解决方案。
这是一个有效的示例,但它确实有一些错误。其中一些来自 jsfiddle 设置。
http://jsfiddle.net/MQBLn/8/
基本上我创建了一个基于单元格格式的函数在列标题尺寸上。
然后只要有一个 Action 就必须调用该函数。 (排序、调整大小等)
另外,我确实必须对 slick.grid.js 进行一些小的更改,因此您会发现它加载在 JS 部分的顶部,然后是自定义 js。然后一些CSS的覆盖规则。
这是我的单元格格式化程序功能,
我希望它有用,也许有一天会作为一项设置内置到 SlickGrid 中。
Yes, it is possible, but I can not find an easy solution.
So you have to customize it quite a bit.
I am currently working on a solution for this.
Here is a working example, but it does have a few bugs. Some of which are from jsfiddle setup.
http://jsfiddle.net/MQBLn/8/
basically I created a function that formats the cells based on the Column Heading Sizes.
Then you have to call that function whenever there is an Action. (Sort, Resize, Etc.)
Also I did have to make some minor changes to slick.grid.js So you will find it loaded at the top of JS section followed by custom js. Then some overwrite rules for css.
Here is my Cell Formatter Function
I hope this is usefull and maybe one day built into SlickGrid as a setting.
SlickGrid 格式化程序为您提供 5 个参数:
您可以使用 dataContext 参数在特定格式化程序等中调整列的宽度:
dataContext.width = 600
使特定列为 600px。示例
每当向网格添加数据后,请记住使用
grid.resizeCanvas();
(重新计算宽度)。The SlickGrid-formatter supply you with 5 parameters:
You can adjust the columns' width using the dataContext parameter, within the specific formatter, etc:
dataContext.width = 600
makes the specific column 600px.Example
Remember to use
grid.resizeCanvas();
(recalculate the widths), whenever you're done adding data to the grid.