Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Listgrid grouping performance issue

    1. version smartgwtpro-4.1d_2013-10-14
    2. Firefox 24.0

    5. Uncaught JavaScript exception [TypeError: _1 is null] in http://127.0.0.1:8888/smartgwttestcanvas/sc/modules/ISC_Grids.js, line 104

    6. Ungroup all and scroll down to start "loading" new records. Hereafter, grouping never stops.
    ----------------------------------------------
    package com._2operate.testcanvas.client;

    import com.google.gwt.core.client.EntryPoint;
    import com.google.gwt.user.client.Random;
    import com.google.gwt.user.client.ui.RootPanel;
    import com.smartgwt.client.types.ListGridFieldType;
    import com.smartgwt.client.widgets.events.ScrolledEvent;
    import com.smartgwt.client.widgets.events.ScrolledHandler;
    import com.smartgwt.client.widgets.grid.ListGrid;
    import com.smartgwt.client.widgets.grid.ListGridField;
    import com.smartgwt.client.widgets.grid.ListGridRecord;
    import com.smartgwt.client.widgets.layout.HLayout;
    import com.smartgwt.client.widgets.layout.VLayout;

    public class SmartGWTProTestCanvas implements EntryPoint {
    ListGrid usersGrid;
    int totalNumberOfUsers = 0;

    public void onModuleLoad() {
    VLayout layout = new VLayout();
    layout.setMembersMargin(10);

    final HLayout parentCanvas = new HLayout();
    parentCanvas.setTop(40);
    parentCanvas.setWidth(600);
    parentCanvas.setHeight(500);
    parentCanvas.setShowEdges(true);
    usersGrid = new ListGrid();
    usersGrid.setHeight100();
    usersGrid.setWidth100();
    usersGrid.setAlternateRecordStyles(true);
    usersGrid.setShowAllRecords(true);
    usersGrid.setIsGroup(true);
    usersGrid.setCanGroupBy(true);
    usersGrid.addScrolledHandler(new ScrolledHandler() {

    public void onScrolled(ScrolledEvent event) {
    Integer[] rows = usersGrid.getVisibleRows();
    int last = rows[1];
    if (last > totalNumberOfUsers) {
    addUsers(5);
    }
    }

    });

    ListGridField userIdField = new ListGridField("id", "Id");
    ListGridField usernameField = new ListGridField("name", "Name");
    ListGridField adminField = new ListGridField("isAdmin", "Administrator");
    ListGridField roleField = new ListGridField("role", "Role");

    usersGrid.setGroupByField("role");
    adminField.setType(ListGridFieldType.BOOLEAN);
    usersGrid.setFields(new ListGridField[] { userIdField, usernameField, adminField, roleField });


    parentCanvas.addMember(usersGrid);
    layout.addMember(parentCanvas);
    layout.draw();
    RootPanel.get("testContainer").add(layout);
    addUsers(100);
    }

    private void addUsers(int numberOfNewUsers) {
    totalNumberOfUsers = totalNumberOfUsers + numberOfNewUsers;
    ListGridRecord[] data = new ListGridRecord[totalNumberOfUsers];
    for (int i = 0; i < numberOfNewUsers; i++) {
    ListGridRecord record = new ListGridRecord();
    record.setAttribute("id", i);
    record.setAttribute("name", "User_" + i);
    record.setAttribute("isAdmin", Random.nextBoolean());
    record.setAttribute("role", getRole());
    data[i] = record;
    }
    usersGrid.setData(data);
    }

    private String getRole() {
    int roleId = Random.nextInt(3);
    String role = "man";
    if (roleId == 0){
    role = "man";
    }
    else if (roleId == 1){
    role = "woman";
    }
    else if (roleId == 2){
    role = "dog";
    }
    return role;
    }
    }

    #2
    Hello world..

    No clues or feedback at all..?

    Comment


      #3
      We investigated this as a possible bug, but it's just a broken test case. You end up with null records in your array, which is fixed by this change:

      Code:
               ListGridRecord[] data = new ListGridRecord[totalNumberOfUsers];
      -        for (int i = 0; i < numberOfNewUsers; i++) {
      +        for (int i = 0; i < totalNumberOfUsers; i++) {
      We did go ahead and adjust the framework code so it ignores nulls rather than crashes, just so this doesn't look like a framework issue to anyone else.

      Comment

      Working...
      X