开发者

Populate data of Default selected table row into another table

I have a requirement which consists of one table at the top and a tab-sheet which cons开发者_如何学运维ists of 3 tabs at the bottom. Within 3 tabs contains 3 different tables, and my requirement here is a when clicked on the top table some related data must be displayed in each of tables in the tab-sheet.

This functionality is working fine for me when I click on the table rows now but the problem here is when application is loaded, in the top table the first row must be selected by default and the related data must be populated and displayed in tab-sheet tables. How can I implement this by using built-in listeners? If example is provided it will be of great help.


Since the functionality is working after clicking a row, I can assume your listener is working properly.

I believe you can just use the top Table's method myTable.setValue(table.firstItemId()) after initializing the view. Assuming that your listener calls (for example) method myApplication.rowSelected(Item item) you can manually call this after setting the table value.

Example:

void init() {
    myTable.addListener(new ItemClickEvent.ItemClickListener() {
        void itemClick(ItemClickEvent event) {
            rowSelected(event.getItem());
        }
    });

    if(!myTable.getItemIds().isEmpty()) {
        Object firstId = myTable.firstItemId();
        myTable.setValue(firstId);
        myTable.rowSelected(myTable.getItem(firstId));
    }
}

void rowSelected(Item item) {
    // Do stuff
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜