Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

Possible bug with grouped ListGrids in Tabs

$
0
0
Hi,

SmartGWT Power 2014-06-22

I have a system that uses Tabs. Based on user selections, the contents under each pane is changed using tabs.updateTab.

Typically, I have a ListGrid under a tab. If I click on one of the record in the list grid I go to a separate pane displaying the details on the selected record. A back button sends the user back to the original list grid.

This works fine, however, if the initial list grid is grouped by one of the column, I get an exception when going back to the List grid and the pane is empty:

Code:

Uncaught JavaScript exception [TypeError: _2 is null] in http://127.0.0.1:8888/test/sc/modules/ISC_Grids.js, line 2610
Use the following code to reproduce. First group the list grid by name, then click "Change". In the new pane, click "Change" button to go back to the grid. The exception above is written to the console and the pane is empty.
(If I do the same exercise without grouping the grid, everything works as expected.)

Code:

            final VLayout canvas1 = new VLayout();
            final VLayout canvas2 = new VLayout();
            final TabSet tabs = new TabSet();
            Tab tab1 = new Tab("Tab1");
            tab1.setPane(canvas1);
            tabs.addTab(tab1);
            tabs.setWidth100();
            tabs.setHeight100();

           
            ListGrid grid = new ListGrid();
        ListGridField field1 = new ListGridField("name");
        ListGridField field2 = new ListGridField("phone");
        grid.setFields(field1, field2);
        grid.setWidth100();
        grid.setHeight(150);
        grid.setData(newPhone(100));
        Button btn1 = new Button("Change");
        btn1.addClickHandler(new ClickHandler() {
           
            @Override
            public void onClick(ClickEvent event) {
                tabs.updateTab(0,canvas2);
            }
        });
        canvas1.addMember(grid);
        canvas1.addMember(btn1);
       
        Button btn2 = new Button("Change");
        btn2.addClickHandler(new ClickHandler() {
           
            @Override
            public void onClick(ClickEvent event) {
                tabs.updateTab(0, canvas1);
            }
        });
        canvas2.addMember(btn2);
        RootPanel.get().add(tabs);

Code:

        Record[] newPhone(int count) {
            int phoneNo = 997654321;
            Record[] phones = new Record[count];
            for(int i = 0; i < count; i++) {
                phoneNo=phoneNo+i;
                Record record = new Record();
                record.setAttribute("name","Ola Nordmann");
                record.setAttribute("phone", ""+phoneNo);
                phones[i] = record;
            }
            return phones;
        }

Regards
Rolf

Viewing all articles
Browse latest Browse all 4756

Trending Articles