简体   繁体   English

Vaadin:在Vaadin中更新网格后,如何关注第一行?

[英]Vaadin: How to focus on first row after updating the grid in Vaadin?

i'm building a Vaadin application with a Grid table within. 我正在构建一个带有网格表的Vaadin应用程序。 The application reloads and updates every minute the table. 应用程序每分钟重新加载和更新表。 SelectionMode.NONE and v-grid-row-focused are used. SelectionMode.NONEv-grid-row-focused Unfortunately, the focus on the first row in the grid table disappears after each data refreshing.After some analysis I found out that after each table reloading the grid returns to v-grid-cell-focused -mode and only after pressing the arraydown-button for scrolling down the row focus it changes to the v-grid-row-focused -mode. 不幸的是,每次刷新数据后,对网格表第一行的关注就消失了。经过一些分析,我发现在每个表重新加载之后,网格返回到v-grid-cell-focused -mode并且仅在按下arraydown按钮之后为了向下滚动行焦点,它将更改为以v-grid-row-focused -mode为单位。 Is there a way to completely disable v-grid-cell-focused -mode? 有没有一种方法可以完全禁用以v-grid-cell-focused模式?

to get the 1st itemId (not Item) of a Table or Grid, you must go through the Container.firstItemId 若要获取表或网格的第一个itemId(而非Item),则必须通过Container.firstItemId

Tables has an assessor method to this, but Grid doesn't 表格有一个评估方法,但网格没有

The solution proposed by Morfic won't work always, because the integer autogenerated by the containers when you use addItem() with no parameters (Indexed and Hierarchical) is incremental, if u clean/remove all/some items, the index will keep growing (not reset to 0) AND the index STARTS from 1, not 0 (if you check the source code), or if your implementation has the capacity to remove Items from the Container and the 1st one is removed, the ZERO index won't exist anymore Morfic提出的解决方案将永远无法工作,因为当您使用无参数(索引和层次结构)的addItem()时,容器自动生成的整数是递增的,如果您清除/删除所有/某些项,索引将继续增长(未重置为0)并且索引从1开始,而不是0(如果您检查了源代码),或者如果您的实现能够从Container中删除项目而第一个已删除,则零索引不会已经存在了

grid.select(grid.getContainerDataSource().getIdByIndex(0));

There is no method in Grid to set focused cell from server side. Grid中没有方法可以从服务器端设置聚焦单元。 However I added such method setFocusedCell(row,col) in GridFastNavigation add-on extension for Vaadin 8. 但是我在Vaadin 8的GridFastNavigation附加扩展中添加了这样的方法setFocusedCell(row,col)。

https://vaadin.com/directory/component/gridfastnavigation-add-on https://vaadin.com/directory/component/gridfastnavigation-add-on

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM