Announcement

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

    ListGrid with ShowRecordComponents is very slow

    Hi,

    Screen freezes or it takes time when I try to re-size columns, show & hide fields and De-selecting records in List Grid.

    I am using following browsers - FF 11 & 17 and IE 8.
    SmartClient Version: v8.3p_2013-02-08/LGPL Development Only (built 2013-02-08)

    Here is the sample code:-

    MainEntryPoint Class
    Code:
    import com.google.gwt.core.client.EntryPoint; 
    import com.smartgwt.client.types.*;
    import com.smartgwt.client.widgets.Button;
    import com.smartgwt.client.widgets.Canvas;
    import com.smartgwt.client.widgets.events.ClickEvent;
    import com.smartgwt.client.widgets.events.ClickHandler;
    import com.smartgwt.client.widgets.form.DynamicForm;
    import com.smartgwt.client.widgets.form.fields.TextItem;
    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.VLayout;
    
    public class MainEntryPoint implements EntryPoint {
    
        private ListGrid table;
    
       
        public MainEntryPoint() {
            table = new ListGrid() {
    
                protected Canvas createRecordComponent(final ListGridRecord record, final Integer colNum) {
                    String fieldName = getFieldName(colNum);
                    if (fieldName.contains("Col")) {
                        return getComponent();
                    }
                    return null;
                }
            };
            table.setWidth100();
            table.setHeight100();
            table.setMinFieldWidth(30);
            table.setGroupStartOpen(GroupStartOpen.ALL);
            table.setShowHeaderContextMenu(false);
            table.setCanFreezeFields(false);
            table.setSelectionType(SelectionStyle.SIMPLE);
            table.setSelectionAppearance(SelectionAppearance.CHECKBOX);
            table.setWrapCells(true);
            table.setScrollRedrawDelay(50);
            table.setHeaderHeight(40);
            table.setHeaderSpanHeight(20);
            table.setCanDragSelect(false);
            table.setFastCellUpdates(false);
            table.setGroupByMaxRecords(10000);
            table.setDataFetchMode(FetchMode.LOCAL);
            table.setEnforceVClipping(true);
            table.setShowAllRecords(false);
            table.setDrawAheadRatio(1000f);
            table.setResizeFieldsInRealTime(false);
            table.setCanEdit(false);
            table.setFields(new ListGridField("Col1", "Field1", 80), new ListGridField("Col2", "Field2", 80), new ListGridField("Col3", "Field3", 80), new ListGridField("Col4", "Field4", 80), new ListGridField("Col5", "Field5", 80), new ListGridField("Col6", "Field6", 80), new ListGridField("Col7", "Field7", 80), new ListGridField("Col8", "Field8", 80), new ListGridField("Col9", "Field9", 80), new ListGridField("Col10", "Field10", 80), new ListGridField("Col11", "Field11", 80), new ListGridField("Col12", "Field12", 80));
            table.setAlternateRecordStyles(false);
            table.setCanReorderFields(false);
            table.setCanReorderRecords(false);
            table.setCellHeight(56);
            table.setCanSort(false);
            table.setFixedRecordHeights(true);
            table.setShowRecordComponents(true);
            table.setShowRecordComponentsByCell(true);
            table.setRecordComponentHeight(56);
            table.setRecordComponentPosition(EmbeddedPosition.WITHIN);
            table.setRecordComponentPoolingMode(RecordComponentPoolingMode.DATA);
            table.setShowTreeColumnPicker(false);
        }
    
    
        public void onModuleLoad() {
    
            VLayout vlayout = new VLayout();
    
            Button hideButton = new Button("Hide");
            hideButton.addClickHandler(new ClickHandler() {
    
                public void onClick(ClickEvent event) {
                    String[] fields = new String[8];
                    fields[0] = "Col12";
                    fields[1] = "Col11";
                    fields[2] = "Col10";
                    fields[3] = "Col9";
                    fields[4] = "Col8";
                    fields[5] = "Col7";
                    fields[6] = "Col6";
                    fields[7] = "Col5";
                    table.hideFields(fields);
                }
            });
            Button showButton = new Button("Show");
            showButton.addClickHandler(new ClickHandler() {
    
                public void onClick(ClickEvent event) {
                    String[] fields = new String[13];
                    fields[1] = "Col1";
                    fields[2] = "Col2";
                    fields[3] = "Col3";
                    fields[4] = "Col4";
                    fields[5] = "Col5";
                    fields[6] = "Col6";
                    fields[7] = "Col7";
                    fields[8] = "Col8";
                    fields[9] = "Col9";
                    fields[10] = "Col10";
                    fields[11] = "Col11";
                    fields[12] = "Col12";
                    table.showFields(fields);
                }
            });
            table.setData(ComponentRecord.getInstance().getListGridRecords());
            vlayout.setWidth100();
            vlayout.setHeight100();
            vlayout.addMember(table);
            vlayout.addMember(hideButton);
            vlayout.addMember(showButton);
            vlayout.setMembersMargin(10);
            vlayout.draw();
    
        }
    
        private DynamicForm getComponent() {
            DynamicForm form = new DynamicForm();
            TextItem text1 = new TextItem();
            TextItem text2 = new TextItem();
            text1.setShowTitle(false);
            text2.setShowTitle(false);
            text1.setWidth(50);
            text2.setWidth(50);
            form.setFields(text1, text2);
            form.setNumCols(1);
            form.setAutoHeight();
            form.setWidth(60);
            return form;
        }
    }
    ComponentRecord Class
    Code:
    import com.smartgwt.client.widgets.grid.ListGridRecord;
    
    public class ComponentRecord {
    
        private static ComponentRecord instance;
    
        public static ComponentRecord getInstance() {
            if (instance == null) {
                instance = new ComponentRecord();
            }
            return instance;
        }
    
        public ListGridRecord[] getListGridRecords() {
            ListGridRecord[] records = new ListGridRecord[18];
    
            for (int i = 0; i < 18; i++) {
                records[i] = new ListGridRecord();
                records[i].setAttribute("Col1", "");
                records[i].setAttribute("Col2", "");
                records[i].setAttribute("Col3", "");
                records[i].setAttribute("Col4", "");
                records[i].setAttribute("Col5", "");
                records[i].setAttribute("Col6", "");
                records[i].setAttribute("Col7", "");
                records[i].setAttribute("Col8", "");
                records[i].setAttribute("Col9", "");
                records[i].setAttribute("Col10", "");
                records[i].setAttribute("Col11", "");
                records[i].setAttribute("Col12", "");
            }
            return records;
        }
    }
    Thanks in Advance...
    Last edited by mehul_lucky4u; 29 May 2013, 05:27. Reason: Missed some data

    #2
    Your drawAheadRatio setting is forcing the entire grid to be rendered. Just remove this setting.

    You have also changed other settings which the docs explicitly tell you have a performance impact (fastCellUpdates, scrollRedrawDelay, recordComponentPoolingMode:"data"). Read the docs to avoid doing this kind of thing.

    Finally, the most recent builds have some optimizations for recordComponents, but note that this will not have an appreciable impact in this profoundly misconfigured grid.

    Comment

    Working...
    X