如何显示jqGrid中的所有行?
jqGrid 公开了一个属性 rowNum
,您可以在其中设置每页显示的行数。 如何将网格设置为仅显示所有行?
现在我只是将 rowNum
设置为非常高的值,例如 <%= int.MaxValue %>
但我想知道是否有更好的方法。
jqGrid exposes a property rowNum
where you can set the number of rows to display for each page. How do you set the grid to just display ALL rows?
Right now I'm just setting the rowNum
to something really high like <%= int.MaxValue %>
but I'm wondering if there is a better way.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(15)
<罢工>
在最新版本的jqGrid中,您可以将rowNum设置为-1来指示网格始终显示所有行:
请参阅最新的jqGrid文档此处。
具体来说:
更新
不幸的是,这种行为在 jqGrid 3.6.3 中被破坏了。 根据托尼的这篇文章:
因此 jqGrid 开发人员意识到了这个问题,并且显然计划在未来的版本中修复它。 不幸的是,这篇文章是一年多前的......
此时,我所能建议的就是将
rowNum
设置为一个非常大的数字来模拟-1
。您还可以尝试下面使用
rowNum: ''
的 Whatispunk 解决方案。 但是,我在包含本地数据的网格上尝试了此操作(loadonce: true
)。 当尝试对行进行排序时,网格的所有本地数据都会消失。 所以这个解决方案似乎不适用于具有本地数据的网格,除非这个缺陷已在jqGrid的更高版本中修复(我在jqGrid 3.8.2上测试过)。 如果您有反馈意见,请在下面发表评论!Update - April 16, 2014
根据 jqGrid 团队的说法,此问题现已修复:
不过,我还没有机会进行测试来确认修复。 据推测,此更改将在 jqGrid 4.6.0 之后的下一个版本中出现。
In the latest version of jqGrid, you can set rowNum to -1 to instruct the grid to always display all rows:
See the latest jqGrid documentation here.
Specifically:
Update
Unfortunately this behavior was broken in jqGrid 3.6.3. According to this post from Tony:
So the jqGrid developers are aware of this problem and apparently are planning to fix it in a future release. Unfortunately this post was from over a year ago...
At this time, all I can recommend is that you set
rowNum
to a very large number to simulate the behavior of-1
.You can also try whatispunk's solution below of using
rowNum: ''
. However, I tried this on a grid containing local data (loadonce: true
). When attemping to sort the rows all of the grid's local data would disappear. So this solution does not seem to work for grids with local data, unless this defect has been fixed in a later version of jqGrid (I tested it on jqGrid 3.8.2). If you have feedback, please post a comment below!Update - April 16, 2014
According to the jqGrid team this is now fixed:
I have not had a chance to test to confirm the fix, though. Presumably this change will be in the next release after jqGrid 4.6.0.
jqgrid(无论如何3.5)似乎没有一个优雅的内置方法来做到这一点。 到目前为止,我发现的最好的方法是将如下内容添加到您的网格选项中:
其中 100000000 是比您将返回的最大行数任意更高的数字,并且 option[value=] 行是您的用户界面看起来更好一点。 Jenky,但为我工作。
jqgrid (3.5 anyway) doesn't seem to have an elegant built in way to do this. The best I have found so far is to add something like the following to your grid options:
Where the 100000000 is some arbitrarily higher number than the maximum # of rows you will ever return, and the option[value=] line is so your user interface looks a little nicer. Jenky, but works for me.
这有效:
This works:
如果您根本不想使用分页,则更改服务器端代码以仅返回所有行。 根本不要使用 rows 参数。
如果您想要拥有行列表,但也有一个显示全部的选项,那么在网格属性中执行类似的操作
,然后在服务器端代码中确保忽略 rows 参数,如果 GET['rows']='ALL'
if you dont wish to use paging at all then change you server side code to simply return all the rows. dont use the rows parameter at all.
if you want to have the rowlist but also have an option to show all then do something like this in the grid properties
and then in the serverside code make sure that you ignore the rows parameter if GET['rows']='ALL'
设置 rowNum:-1 为我解决了这个问题
setting
rowNum:-1
did the trick for me如果您在导航栏上设置了分页,您还可以访问网格右下角写入的总行数,然后附加到生成的 RowList 选项。
做类似的事情:
If you have set the pagination on the navbar, you can also access to the total number of rows written on the right-bottom of the grid and then append to the generated RowList option.
Do something like :
设置 rowNum: '' 您将获得所有行。
Setting rowNum: '' you get all rows.
我已经得到了这个工作:
无论是否将
loadOnce
选项设置为 true,这都有效。 请注意,您必须首先将rowNum
选项设置为 0,如果您省略此选项,它仍会默认显示 20 条记录。另外,我假设您以记录的 JSON 读取器格式从服务器返回总行数。
I've got this working:
This works with and without the
loadOnce
option set to true. Note that you have to set therowNum
option to 0 first, if you leave out this option it'll still default to the 20 records to show.Also, I'm assuming you're returning the total rows from the server in the documented JSON reader format.
通过简单的更改解决了它:
rowNum: inputDataArray.length
其中 inputDataArray 是我提供给网格的数组。
resolved it with simple change:
rowNum: inputDataArray.length
where inputDataArray is the array that I am providing to the Grid.
默认情况下,JQ 网格最多显示 20 行,如果您不使用分页:
By default the JQ grid show 20 rows Max ,if you are using not using pagination:
您还可以进入 jquery.jqGrid.js 并将“rowNum:20”更改为“rowNum:Some-Really-Large-Number”。 定义 jqGrid 时,不要指定 rowNum。 然后将整个数据集返回到 jqGrid。
You can also go into jquery.jqGrid.js and change "rowNum:20" to "rowNum:Some-Really-Large-Number". When you define your jqGrid, don't specify rowNum. Then return your entire dataset back to jqGrid.
即使它仍然出现在文档中,从 jqGrid 4.5.4 开始,您无法将 rowNum 设置为 -1,它仍然可以再次工作(也许在早期版本中也是如此)。
Even if it still appears in the doc that you cannot set rowNum to -1 as of jqGrid 4.5.4 it works again (maybe in earlier version too).
这会将“ALL”选项更改为数据集中的实际记录数。
This changes the "ALL" option to the actual number of records in the dataset.
设置
rowNum:-1
对我来说很有效,之后它显示了所有记录,但在网格页脚中仍然有行号选项,如下所示:要删除此内容,我只需添加了一个 css 选项,通过在 jquery 中获取扇区来显示无。 像这样
注意:这个css设置应该在网格加载完成时完成。
Setting
rowNum:-1
works for me like, after that it was showing all records but it still has row number option in grid footer like this:To remove this I just added a css option display none by getting the sector in jquery. Like this
Note: This css setting should be done when the grid load is completed.