Announcement

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

    Bug with ListGrid populated with setData

    1. Problem persists on all currently downloadable LGPL versions of SmartGWT
    2. Problem persists on currently latest versions of these browsers: IE, FF, Chrome, Safari for Windows
    3. SmartGWT 6.0.d LGPL
    4. GWT 2.5.1
    5. Windows 7x64
    6. Any mode: standard, hosted, normal browser

    Problem description:
    a. Created ListGrid populated with dummy data (with setData) not have DataSource, 2 of columns are editable, others are readonly
    b. ListGrid is placed on screen
    c. If i first time click on 1st editable column (col 3 in my example) on some row, i can edit cell, all is fine.
    d. If i then try to edit the same column, but for another row i got error and app crashes (no reaction on user actions)
    e. Also bugs when i try to edit several times last column (checkbox)
    Last edited by nickv; 23 Feb 2015, 13:17.

    #2
    JavaScript stack trace

    Code:
    04:32:15.850 [ERROR] [fin] 04:32:15.842:pointerup5:WARN:Log:TypeError: Unable to get property '$11e' of undefined or null reference
    Stack from error.stack:
        FormItem._absPos () @ fin/sc/modules/ISC_Forms.js:631:215
        FormItem.getStandaloneItemHTML () @ fin/sc/modules/ISC_Forms.js:662:404
        ListGrid.getEditItemCellValue () @ fin/sc/modules/ISC_Grids.js:1371:30
        ListGrid.getCellValue () @ fin/sc/modules/ISC_Grids.js:1314:66
        Function code () @ Function code:1:89
        GridRenderer._getCellValue () @ fin/sc/modules/ISC_Grids.js:468:323
        GridRenderer.refreshCellValue () @ fin/sc/modules/ISC_Grids.js:570:1
        GridBody.refreshCellValue () @ fin/sc/modules/ISC_Grids.js:726:1
        ListGrid.refreshCellValue () @ fin/sc/modules/ISC_Grids.js:1870:16
        ListGrid.refreshCell () @ fin/sc/modules/ISC_Grids.js:1863:93
    
    
    com.smartgwt.client.core.JsObject$SGWT_WARN: 04:32:15.842:pointerup5:WARN:Log:TypeError: Unable to get property '$11e' of undefined or null reference
    Stack from error.stack:
        FormItem._absPos () @ fin/sc/modules/ISC_Forms.js:631:215
        FormItem.getStandaloneItemHTML () @ fin/sc/modules/ISC_Forms.js:662:404
        ListGrid.getEditItemCellValue () @ fin/sc/modules/ISC_Grids.js:1371:30
        ListGrid.getCellValue () @ fin/sc/modules/ISC_Grids.js:1314:66
        Function code () @ Function code:1:89
        GridRenderer._getCellValue () @ fin/sc/modules/ISC_Grids.js:468:323
        GridRenderer.refreshCellValue () @ fin/sc/modules/ISC_Grids.js:570:1
        GridBody.refreshCellValue () @ fin/sc/modules/ISC_Grids.js:726:1
        ListGrid.refreshCellValue () @ fin/sc/modules/ISC_Grids.js:1870:16
        ListGrid.refreshCell () @ fin/sc/modules/ISC_Grids.js:1863:93
    
        at sun.reflect.GeneratedConstructorAccessor59.newInstance(Unknown Source)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
        at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:105)
        at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
        at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
        at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:293)
        at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:547)
        at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)
        at java.lang.Thread.run(Thread.java:662)

    Comment


      #3
      Source

      Code:
      package com.d8corp.fin.client.view;
      
      import java.util.ArrayList;
      import java.util.Date;
      import java.util.LinkedHashMap;
      import java.util.List;
      
      
      
      import com.d8corp.fin.client.presenter.FinPresenter.Display;
      import com.d8corp.fin.client.record.BalanceRecord;
      
      import com.google.gwt.user.client.ui.Composite;
      import com.google.gwt.user.client.ui.Widget;
      
      import com.smartgwt.client.data.Record;
      import com.smartgwt.client.data.RecordList;
      import com.smartgwt.client.types.ChartType;
      import com.smartgwt.client.types.GroupStartOpen;
      import com.smartgwt.client.types.ListGridEditEvent;
      import com.smartgwt.client.types.Overflow;
      import com.smartgwt.client.types.RowEndEditAction;
      import com.smartgwt.client.types.SelectionAppearance;
      import com.smartgwt.client.types.SelectionStyle;
      
      import com.smartgwt.client.widgets.Button;
      import com.smartgwt.client.widgets.Canvas;
      //import com.smartgwt.client.widgets.events.ResizedEvent;
      //import com.smartgwt.client.widgets.events.ResizedHandler;
      import com.smartgwt.client.widgets.form.DynamicForm;
      import com.smartgwt.client.widgets.form.fields.SelectItem;
      import com.smartgwt.client.widgets.grid.HeaderSpan;
      import com.smartgwt.client.widgets.grid.ListGrid;
      import com.smartgwt.client.widgets.grid.ListGridField;
      import com.smartgwt.client.types.ListGridFieldType;
      import com.smartgwt.client.widgets.grid.ListGridRecord;
      import com.smartgwt.client.widgets.grid.events.RowEditorExitEvent;
      import com.smartgwt.client.widgets.grid.events.RowEditorExitHandler;
      import com.smartgwt.client.widgets.layout.HLayout;
      import com.smartgwt.client.widgets.layout.VLayout;
      import com.smartgwt.client.widgets.tab.Tab;
      import com.smartgwt.client.widgets.tab.TabSet;
      
      import com.smartgwt.client.widgets.grid.CellFormatter;
      import com.smartgwt.client.data.SortSpecifier;
      import com.smartgwt.client.types.SortDirection;
      
      import com.google.gwt.i18n.client.NumberFormat;
      
      
      public class FinView extends Composite implements Display {
      	
      	public static final int groupingFieldWidth = 140;//150;
      	
      	private static final String[] sortFieldsArray = null;//{"company"};
      	private static final String[] groupFieldsArray = null;//{"company"};
      
      	private static final NumberFormat numberMoney = NumberFormat.getFormat("#,###,##0.00");
      	
      	public final String[] getSortFieldsArray() {
      		String[] result = null;
      		result = sortFieldsArray;			
      		return result;
      	}
      
      	public final String[] getGroupFieldsArray() {
      		String[] result = null;
      		result = groupFieldsArray;			
      		return result;
      	}
      	
      	public Widget getRootWidget() {
      		return this;
      	}
      	
      	public FinView() {
      		//final TabSet tabPanel = createTabPanel();
      		final VLayout vLayout = new VLayout();
      		vLayout.setWidth100();
      		vLayout.setHeight100();
      		VLayout balancesEntryContainer = createBalancesFilterAndTableContainer();
      		//vLayout.addMember(tabPanel);
      		vLayout.addMember(balancesEntryContainer);
      		initWidget(vLayout);
      	}
      
      	private TabSet createTabPanel() {
      		final TabSet result = new TabSet();
      		//Balances
      		VLayout balancesEntryContainer = createBalancesFilterAndTableContainer();
      		final Tab balancesEntryTab = new Tab("Balances entry");
      		balancesEntryTab.setPane(balancesEntryContainer);
      		result.addTab(balancesEntryTab);
      		return result;
      	}
      	
      	private Button balancesReadDataButton;
      	public Button getBalancesReadDataButton() {
      		return balancesReadDataButton;
      	}	
      	private Button balancesWriteDataButton;
      	public Button getBalancesWriteDataButton() {
      		return balancesWriteDataButton;
      	}
      	private Button balancesCancelDataButton;
      	public Button getBalancesCancelDataButton() {
      		return balancesCancelDataButton;
      	}	
      	
      	private HLayout createBalancesRWButtonsForm() {
      		balancesReadDataButton = new Button("Read data");
      		balancesWriteDataButton = new Button("Write data");
      		balancesWriteDataButton.disable();
      		balancesCancelDataButton = new Button("Cancel edits");
      		balancesCancelDataButton.disable();		
      		final HLayout result = new HLayout();
      		result.addMember(balancesReadDataButton);
      		result.addMember(balancesWriteDataButton);
      		result.addMember(balancesCancelDataButton);
      		
      		return result;
      	}
      	
      	private void createBalancesFilters() {
      		
      		final HLayout buttonsForm = createBalancesRWButtonsForm();
      	    final HLayout hLayout = new HLayout();
      	    hLayout.addMember(buttonsForm);
         
      	    balancesFiltersPanel.addMember(hLayout);
      	}    
          
      	private VLayout balancesFiltersPanel;
      	public void createBalancesFiltersPanel() {
      		createBalancesFilters();
      	}
      	
      	private ListGrid balancesBaseAssetGrid;
      	public ListGrid getBalanceAssetsGrid() {
      		return balancesBaseAssetGrid;
      	}
      
      	public void setYearBalances(boolean clear) {	
      		ListGridField[] balancesBaseAssetsFields = getBalancesBaseFields(true, true);
      		balancesBaseAssetGrid.setFields(balancesBaseAssetsFields);	
      
      		String[] balanceSortFields = getSortFieldsArray();
      		String[] balanceGroupFields = getGroupFieldsArray();	
      		sortAndGroupGrid(balancesBaseAssetGrid, balanceSortFields, balanceGroupFields);
      		
      		RecordList balanceBaseAssetRecords = getBalancesBaseRecords(clear);
      		balancesBaseAssetGrid.setData(balanceBaseAssetRecords);
      	}
      	
      	private ListGrid getBalancesBaseGrid() {
      	    final ListGrid result = new ListGrid();
      	    result.setShowAllRecords(true);  
      	    result.setCanEdit(true);
      	    result.setEditByCell(true);
      	    result.setCanFreezeFields(false);
      	    result.setCanSort(false);
      	    result.setShowHeader(true);
              //result.setShowGroupSummary(true);
              //result.setShowGroupSummaryInHeader(true);        
              
              //ListGridField groupingField = new ListGridField("dummy", "Grouping", 150);
              //result.setGroupTitleColumnProperties(groupingField);
              
              //result.setGroupStartOpen(GroupStartOpen.ALL);
      
              result.setEditEvent(ListGridEditEvent.CLICK);  
              result.setListEndEditAction(RowEndEditAction.NEXT);  
              result.setAutoSaveEdits(false);
       
      		result.addRowEditorExitHandler(new RowEditorExitHandler() {
      			public void onRowEditorExit(RowEditorExitEvent event) {				                               
                      int rowNum = event.getRowNum();
                      System.out.println("rowNum = [" + rowNum + "]");
                      int colNum = result.getFieldNum("sumBase");
                      System.out.println("colNum = [" + colNum + "]");
                      Record record = result.getEditedRecord(rowNum);
                      String tmp = null;
                      tmp = record.getAttributeAsString("exchangeRate");
                      Double exchangeRate = Double.valueOf(tmp);
                      System.out.println("rate = [" + exchangeRate + "]");
                      tmp = record.getAttributeAsString("sumCur");
                      Double sumCur = Double.valueOf(tmp);
                      System.out.println("sum = [" + sumCur + "]");
                      Double value = exchangeRate * sumCur;
                      System.out.println("val = [" + value + "]");                
                      result.setEditValue(rowNum, colNum, value);                
                     				
      				balancesReadDataButton.setDisabled(result.hasChanges());
      				balancesWriteDataButton.setDisabled(!result.hasChanges());
      				balancesCancelDataButton.setDisabled(!result.hasChanges());				
      			}
      		});
      		        
              return result;
      	}
      	
      	private void createBalancesTable() {
      		balancesBaseAssetGrid = getBalancesBaseGrid();
      		setYearBalances(false);
      
      		final HLayout hLayout = new HLayout();
      		hLayout.setWidth100();
      		hLayout.addMember(balancesBaseAssetGrid);
          
      	    balancesTablePanel.addMember(hLayout);		
      	}
      	
      	private VLayout balancesTablePanel;
      	public void createBalancesTablePanel() {
      		createBalancesTable();
      	}
      	
      	private VLayout createBalancesFilterAndTableContainer() {
      		
      	    balancesFiltersPanel = new VLayout();
      	    balancesFiltersPanel.setWidth100();
      	    balancesFiltersPanel.setHeight("5%");
      		
      	    balancesTablePanel = new VLayout();
      	    balancesTablePanel.setWidth100();
      	    balancesTablePanel.setHeight("95%");
      
      	    final VLayout result = new VLayout();
      		result.addMember(balancesFiltersPanel);
      		result.addMember(balancesTablePanel);
      		
      		return result;
      	}
      	
      	private RecordList getBalancesBaseRecords(boolean clear) {
      		RecordList result = new RecordList();
      		if (!clear)
      		for (int i = 1; i <= 10; i++) {			
      			BalanceRecord balanceRecord = new BalanceRecord();
      			
      			Long id = new Long(i);
      			balanceRecord.setId(id);
      			
      			Double exchangeRate = new Double(1.0d*id);
      			balanceRecord.setExchangeRate(exchangeRate);    		
      				
      			Long companyId = id;
      			String companyName = "Company"+id;
      			balanceRecord.setCompanyId(companyId);        	
      			balanceRecord.setCompany(companyName);
      			
      			Long currencyId = id;
      			String currency = "Currency"+id;
      			balanceRecord.setCurrencyId(currencyId);
      			balanceRecord.setCurrency(currency);
      			
      			Long balTypeId = id;
      			String balType = "BalType"+id;
      			balanceRecord.setBalTypeId(balTypeId);
      			balanceRecord.setBalType(balType);
      							
      			Double sumCur = 1.0d*id;
      			balanceRecord.setSumCur(sumCur);
      			
      			Double sumBase = exchangeRate * sumCur;
      			balanceRecord.setSumBase(sumBase);
      			
      			int yyyy = 2015;
      			int mm = 1;
      			int dd = 1;
      			int yyyymmdd = yyyy * 100 * 100 + mm * 100 + dd;
      			Long balanceYMD = new Long(yyyymmdd);
      			balanceRecord.setBalanceYMD(balanceYMD);
      			
      			Boolean isActive = new Boolean(false);
      			balanceRecord.setIsActive(isActive);
      			result.add(balanceRecord);		
      		}
      		return result;
      	}	
      	
      	private CellFormatter sumCellFormatter = new CellFormatter() {
      		@Override
      		public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
      			String result = null;
      			String str = (value == null) ? "-" : String.valueOf(value);
      			String tmp = (str.equals("-")) ? "-" : numberMoney.format(Double.valueOf(str));
      			result = tmp.replace(",", " ");
      			return result;
      		}
          };
      	
      	private ArrayList<ListGridField> getBalanceBaseMainFields(Boolean defaultCurrency, Boolean firstGrid) {
      		ArrayList<ListGridField> result = new ArrayList<ListGridField>();
      	
      		String fieldName;
      		String fieldTitle;
      		int fieldWidth;
      		ListGridField listGridField;
      	
      		fieldWidth = 0;
      		fieldName = "id";
      		fieldTitle = fieldWidth == 0 ? "" : "ID";		
              listGridField = new ListGridField(fieldName, fieldTitle, fieldWidth);
              listGridField.setType(ListGridFieldType.INTEGER);
              listGridField.setCanEdit(false);
              listGridField.setFrozen(true);
              listGridField.setHidden(fieldWidth == 0);
              listGridField.setCanSort(false);
              result.add(listGridField);
          	
      		fieldWidth = firstGrid ? 155 : 155;
      		fieldName = "company";
      		fieldTitle = fieldWidth == 0 ? "" : "Company";
      		listGridField = new ListGridField(fieldName, fieldTitle, fieldWidth);
      		listGridField.setType(ListGridFieldType.TEXT);        
      		listGridField.setCanEdit(false);
      		listGridField.setFrozen(true);
      		listGridField.setHidden(fieldWidth == 0);        
      		listGridField.setCanSort(false);
      		result.add(listGridField);
      
      		fieldWidth = 0;
      		fieldName = "companyId";
      		fieldTitle = fieldWidth == 0 ? "" : "CompanyId";
      		listGridField = new ListGridField(fieldName, fieldTitle, fieldWidth);
      		listGridField.setType(ListGridFieldType.INTEGER);
      		listGridField.setCanEdit(false);
      		listGridField.setFrozen(true);
              listGridField.setHidden(fieldWidth == 0);
              listGridField.setCanSort(false);
              result.add(listGridField);  
              
      		fieldWidth = 0;
      		fieldName = "balTypeId";
      		fieldTitle = fieldWidth == 0 ? "" : "BalTypeId";
      		listGridField = new ListGridField(fieldName, fieldTitle, fieldWidth);
      		listGridField.setType(ListGridFieldType.INTEGER);
      		listGridField.setCanEdit(false);
      		listGridField.setFrozen(true);
              listGridField.setHidden(fieldWidth == 0);
              listGridField.setCanSort(false);
              result.add(listGridField);      
              	
      		fieldWidth = 0;
      		fieldName = "balanceYMD";
      		fieldTitle = fieldWidth == 0 ? "" : "BalanceYMD";
      		listGridField = new ListGridField(fieldName, fieldTitle, fieldWidth);
      		listGridField.setType(ListGridFieldType.INTEGER);
      		listGridField.setCanEdit(false);
      		listGridField.setFrozen(true);
              listGridField.setHidden(fieldWidth == 0);
              listGridField.setCanSort(false);
              result.add(listGridField);
              
      		fieldWidth = 0;
      		fieldName = "currencyId";
      		fieldTitle = fieldWidth == 0 ? "" : "CurrencyId";
      		listGridField = new ListGridField(fieldName, fieldTitle, fieldWidth);
      		listGridField.setType(ListGridFieldType.INTEGER);        
      		listGridField.setCanEdit(false);
              listGridField.setFrozen(true);
              listGridField.setHidden(fieldWidth == 0);
              listGridField.setCanSort(false);
              result.add(listGridField);
              
      		fieldWidth = 100;
      		fieldName = "exchangeRate";
      		fieldTitle = fieldWidth == 0 ? "" : "Rate";        
      		listGridField = new ListGridField(fieldName, fieldTitle, fieldWidth);        
      		listGridField.setType(ListGridFieldType.FLOAT);
      		listGridField.setCanEdit(!defaultCurrency);
      		//listGridField.setCanEdit(true);
      		listGridField.setFrozen(true);
      		listGridField.setHidden(fieldWidth == 0);
      		listGridField.setCanSort(false);
      		result.add(listGridField);
      		
      		fieldWidth = 150;
      		fieldName = "sumCur";
      		fieldTitle = fieldWidth == 0 ? "" : "Sum in selected currency";        
      		listGridField = new ListGridField(fieldName, fieldTitle, fieldWidth);        
      		listGridField.setType(ListGridFieldType.FLOAT);
      		listGridField.setCanEdit(true);
      		listGridField.setFrozen(true);
      		listGridField.setHidden(fieldWidth == 0);
      		listGridField.setCanSort(false);	
      		listGridField.setCellFormatter(sumCellFormatter);
      		result.add(listGridField);
      		        
      		fieldWidth = 150;
      		fieldName = "sumBase";
      		fieldTitle = fieldWidth == 0 ? "" : "Sum in base currency";        
      		listGridField = new ListGridField(fieldName, fieldTitle, fieldWidth);        
      		listGridField.setType(ListGridFieldType.FLOAT);
      		listGridField.setCanEdit(false);
      		listGridField.setFrozen(true);
      		listGridField.setHidden(fieldWidth == 0);
      		listGridField.setCanSort(false);
      		listGridField.setCellFormatter(sumCellFormatter);
      		result.add(listGridField);
      
      		fieldWidth = 100;
      		fieldName = "isActive";
      		fieldTitle = fieldWidth == 0 ? "" : "Active";        
      		listGridField = new ListGridField(fieldName, fieldTitle, fieldWidth);        
      		listGridField.setType(ListGridFieldType.BOOLEAN);
      		listGridField.setCanEdit(true);
      		listGridField.setFrozen(true);
      		listGridField.setHidden(fieldWidth == 0);
      		listGridField.setCanSort(false);
      		result.add(listGridField);
      		
      		return result;								
      	}
      	
      	public ListGridField[] getBalancesBaseFields(Boolean defaultCurrency, Boolean firstGrid) {
      		ListGridField[] result = null;
      		ArrayList<ListGridField> fields = new ArrayList<ListGridField>();
              ArrayList<ListGridField> mainFields = getBalanceBaseMainFields(defaultCurrency, firstGrid);
              ArrayList<ListGridField> periodFields = new ArrayList<ListGridField>();
              fields.addAll(mainFields);
              fields.addAll(periodFields);
              result = fields.toArray(new ListGridField[0]); 
              return result;
      	}	
      	
      	private final static SortSpecifier[] getSortSpecifiers(String[] sortFields) {
      		SortSpecifier[] result = null;
      		List<SortSpecifier> sortSpecifiers = new ArrayList<SortSpecifier>();
      		for (String sortField: sortFields) {
      			SortSpecifier sortSpecifier = new SortSpecifier(sortField, SortDirection.ASCENDING);
      			sortSpecifiers.add(sortSpecifier);
      		}
      		result = sortSpecifiers.toArray(new SortSpecifier[0]);
      		return result;
      	}
      	
      	private void sortAndGroupGrid(final ListGrid listGrid, final String[] sortFields, final String[] groupFields) {
      		if (sortFields != null) {
      			SortSpecifier[] sortSpecifiers = getSortSpecifiers(sortFields);
      			listGrid.setSort(sortSpecifiers);
      		}
      		if (groupFields != null) {
      			listGrid.setGroupByMaxRecords(2000);
      			listGrid.groupBy(groupFields);			
      		}
      	}
      }

      Comment


        #4
        Response

        Dear, Isomorphic

        Please take a look at this problem, the case to reproduce error is very simple... it's described.
        Please let me know if this ticket is formed wrong as well ...

        Comment


          #5
          Resolved

          This was because all ListGrid's fields were created with setFrozen(true);
          setting setFrozen(false) for last field or just commenting setting of this attribute in code solves situation, UI no more hangs

          Comment

          Working...
          X