是否可以根据父div大小而不是行数来设置Dojo / Dijit DataGrid自动高亮功能? [英] Is it possible to have Dojo/Dijit DataGrid autoheight functionality based on the parent div size instead of a number of rows?

查看:139
本文介绍了是否可以根据父div大小而不是行数来设置Dojo / Dijit DataGrid自动高亮功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个datagrid定期更新,其中的行数随时间稳定增长。它位于父级div中,高度为屏幕的60%。

I have a datagrid that is updated periodically and the number of rows inside it grows steadily over time. It is inside of a parent div with a height of 60% of the screen.

如果我将autoheight设置为5行,表格正常工作。当添加第六行时,数据网格中会显示一个滚动条,我可以向上/向下滚动,标题保持固定在顶部并可见。不幸的是,一旦我有很多数据,这是浪费空间 - 我有60%的屏幕高度可以使用,但一次只显示5行。

If I set autoheight to, say, 5 rows, the table works properly. When a sixth row is added, a scrollbar appears within the datagrid and I can scroll up/down and the headers remain fixed at the top and visible. Unfortunately, once I have a lot of data, this is a waste of space -- I have 60% of the screen's height to work with, but only 5 rows are being shown at a time.

如果我将autoheight设置为false,则显示的滚动条将附加到父div。向上/向下滚动允许我查看数据,但网格顶部的标题滚动出来。

If I set autoheight to false, the scrollbar that appears is attached to the parent div. Scrolling up/down allows me to see the data, but the headers at the top of the grid scroll out of view.

有没有办法要求datagrid显示尽可能多的行,并为其余的行提供滚动条?

Is there a way to ask the datagrid to show as many rows as it can fit and provide a scrollbar for the rest?

----编辑----

---- EDIT ----

如果在调整浏览器大小时,如果datagrid与父进程一起调整大小,那么将autoheight设置为false将正好是我想要的。有没有一个很好的方法来实现?

Setting autoheight to false would be exactly what I want if the datagrid would resize itself along with the parent when I resize my browser. Is there a good way to achieve that?

推荐答案

我想你正在寻找grid.resize();如果您在dojox的夜间文件中查看文件Grid.js.uncompressed.js: http://archive.dojotoolkit.org/nightly/dojotoolkit/dojox/grid/ 您可以确切地看到它的作用。 dataGrid应该继承这个方法,如果你使用它。使用它的一种方法是根据窗口的高度调整包含div的大小,然后调整网格内的大小:

I think you're looking for grid.resize(); If you look at the file "Grid.js.uncompressed.js" in the dojox nightly files here: http://archive.dojotoolkit.org/nightly/dojotoolkit/dojox/grid/ You can see exactly what it does. The dataGrid should inherit this method, if you're using it. One way to use it is to resize the containing div based on the window's height, and then resize the grid inside:

function changeHeight() {
    document.getElementById("div Id in which the dojo grid is there").style.height ="your desired height";
    dijit.byId('Id of the dojo grid').resize();
    dijit.byId('Id of the dojo grid').update();
}

另一种选择方法是做这样的事情:

Another option method is do do something like this:

function resizeGrid() {
   // do whatever you need here, e.g.:
   myGrid.resize();
   myGrid.update();
}

dojo.addOnLoad(function() {
    dojo.connect(window, "onresize", resizeGrid);
});

这篇关于是否可以根据父div大小而不是行数来设置Dojo / Dijit DataGrid自动高亮功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆