Results 1 to 3 of 3

Thread: Live Group Summary : NullPointer exception when no groupBy parameter is present

  1. #1
    Sencha User
    Join Date
    Aug 2009
    Posts
    26
    Vote Rating
    0
      0  

    Default Live Group Summary : NullPointer exception when no groupBy parameter is present

    Hi,

    I am trying to make an Editable Grid but without any grouping of columns.

    Hence I commented the line 'store.groupBy("project");' and tried to edit the 'estimate' and 'rate' columns in the demo example of Live Group Summary Grid ( http://www.extjs.com/examples/#livegroupsummary ).

    The values get changed alright but I get a null pointer exception when I try to move the focus away from the modified column.

    I have tried the code with both GXT 2.1 and 2.0.1 versions.

    It works fine if I set the groupBy parameter (as shown in the demo). The problem occurs upon removing the groupBy parameter.

    Has anyone faced this issue before?..

    Thanks.

    Error log:

    Code:
    java.lang.NullPointerException: null
     at com.extjs.gxt.ui.client.data.NestedModelUtil.isNestedProperty(NestedModelUtil.java:71)
     at com.extjs.gxt.ui.client.data.BaseModelData.get(BaseModelData.java:44)
     at com.extjs.gxt.ui.client.widget.grid.GroupingView.onRemove(GroupingView.java:408)
     at com.extjs.gxt.ui.client.widget.grid.GroupSummaryView.onRemove(GroupSummaryView.java:152)
     at com.extjs.gxt.ui.client.widget.grid.GridView.refreshRow(GridView.java:1490)

    Code:

    Code:
    import java.util.ArrayList;
    import java.util.List;
    import java.util.Map;
    import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
    import com.extjs.gxt.ui.client.data.BaseModelData;
    import com.extjs.gxt.ui.client.store.GroupingStore;
    import com.extjs.gxt.ui.client.store.ListStore;
    import com.extjs.gxt.ui.client.widget.ContentPanel;
    import com.extjs.gxt.ui.client.widget.form.NumberField;
    import com.extjs.gxt.ui.client.widget.grid.CellEditor;
    import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
    import com.extjs.gxt.ui.client.widget.grid.ColumnData;
    import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
    import com.extjs.gxt.ui.client.widget.grid.EditorGrid;
    import com.extjs.gxt.ui.client.widget.grid.Grid;
    import com.extjs.gxt.ui.client.widget.grid.GridCellRenderer;
    import com.extjs.gxt.ui.client.widget.grid.GroupSummaryView;
    import com.extjs.gxt.ui.client.widget.grid.SummaryColumnConfig;
    import com.extjs.gxt.ui.client.widget.grid.SummaryRenderer;
    import com.extjs.gxt.ui.client.widget.grid.SummaryType;
    import com.extjs.gxt.ui.client.widget.layout.FitLayout;
    import com.google.gwt.core.client.EntryPoint;
    import com.google.gwt.i18n.client.NumberFormat;
    import com.google.gwt.user.client.ui.RootPanel;
     
    public class EditableGrid implements EntryPoint {
     
      /**
       * Constructor
       */
      private EditableGrid(){
     
      }
     /**
      * This is the entry point method.
      */
     public void onModuleLoad() {
     
      System.out.println("Inside");
         List<Task> tasks = getTasks();   
         GroupingStore<Task> store = new GroupingStore<Task>();   
     
         /*Commenting the groupBy parameter*/
         //store.groupBy("project");   
         store.add(tasks);   
     
         List<ColumnConfig> columns = new ArrayList<ColumnConfig>();   
     
         SummaryColumnConfig<Integer> desc = new SummaryColumnConfig<Integer>("description", "Task", 65);   
         desc.setSummaryType(SummaryType.COUNT);   
         desc.setSummaryRenderer(new SummaryRenderer() {   
           public String render(Number value, Map<String, Number> data) {   
             return value.intValue() > 1 ? "(" + value.intValue() + " Tasks)" : "(1 Task)";   
           }   
         });   
     
         SummaryColumnConfig<Double> project = new SummaryColumnConfig<Double>("project", "Project", 55);   
         SummaryColumnConfig<Double> due = new SummaryColumnConfig<Double>("due", "Due Date", 20);   
     
         SummaryColumnConfig<Double> estimate = new SummaryColumnConfig<Double>("estimate", "Estimate", 20);   
         estimate.setRenderer(new GridCellRenderer<Task>() {   
           public String render(Task model, String property, ColumnData config, int rowIndex, int colIndex,   
               ListStore<Task> store, Grid<Task> grid) {   
             return model.get(property) + " hours";   
           }   
         });   
         estimate.setSummaryType(SummaryType.SUM);   
         estimate.setSummaryRenderer(new SummaryRenderer() {   
           public String render(Number value, Map<String, Number> data) {   
             return value.intValue() + " hours";   
           }   
         });   
         estimate.setEditor(new CellEditor(new NumberField()));   
     
         SummaryColumnConfig<Double> rate = new SummaryColumnConfig<Double>("rate", "Rate", 20);   
         rate.setNumberFormat(NumberFormat.getCurrencyFormat());   
         rate.setSummaryFormat(NumberFormat.getCurrencyFormat());   
         rate.setSummaryType(SummaryType.AVG);   
         rate.setAlignment(HorizontalAlignment.RIGHT);   
     
         NumberField nf = new NumberField();   
         nf.setAutoValidate(true);   
         CellEditor ce = new CellEditor(nf);   
         ce.setCancelOnEsc(true);   
         rate.setEditor(ce); 
     
         columns.add(desc);   
         columns.add(project);   
         columns.add(due);   
         columns.add(estimate);   
         columns.add(rate);   
     
         ColumnModel cm = new ColumnModel(columns);   
     
         GroupSummaryView summary = new GroupSummaryView();   
         summary.setForceFit(true);   
         summary.setShowGroupedColumn(false);   
     
         EditorGrid<Task> grid = new EditorGrid<Task>(store, cm);   
         grid.setBorders(true);   
         grid.setView(summary);   
         grid.getView().setShowDirtyCells(false);   
     
         ContentPanel panel = new ContentPanel();   
         panel.setHeading("Sponsored Projects");        
         panel.setCollapsible(true);   
         panel.setFrame(true);   
         panel.setSize(800, 450);   
         panel.setLayout(new FitLayout());   
         panel.add(grid);   
         RootPanel.get().add(panel);    
     }
     
     public List<Task> getTasks() {
      List<Task> tasks = new ArrayList<Task>();
      tasks.add(new Task(100, "Ext Forms: Field Anchoring", 112, "Integrate 2.0 Forms with 2.0 Layouts", 6, 150, "06/24/2007"));
      tasks.add(new Task(100, "Ext Forms: Field Anchoring", 113, "Implement AnchorLayout", 4, 150, "06/25/2007"));
      tasks.add(new Task(100, "Ext Forms: Field Anchoring", 114, "Add support for multiple types of anchors", 4, 300, "06/27/2007"));
      tasks.add(new Task(100, "Ext Forms: Field Anchoring", 115, "Testing and debugging", 8, 150, "06/29/2007"));
      tasks.add(new Task(101, "Ext Grid: Single-level Grouping", 101, "Add required rendering 'hooks' to GridView", 6, 100, "07/01/2007"));
      tasks.add(new Task(101, "Ext Grid: Single-level Grouping", 102, "Extend GridView and override rendering functions", 4, 0, "07/03/2007"));
      tasks.add(new Task(101, "Ext Grid: Single-level Grouping", 103, "Extend Store with grouping functionality", 4, 100, "07/04/2007"));
      tasks.add(new Task(101, "Ext Grid: Single-level Grouping", 121, "Default CSS Styling", 2, 350, "07/05/2007"));
      tasks.add(new Task(101, "Ext Grid: Single-level Grouping", 104, "Testing and debugging", 6, 100, "07/06/2007"));
      return tasks;
     }
     
     class Task extends BaseModelData {
      public Task(int id, String project, int taskId, String desc, double estimate, double rate, String due) {
       setId(id);
       setProject(project);
       setTaskId(taskId);
       setDescription(desc);
       setEstimate(estimate);
       setRate(rate);
       setDue(due);  
      }
     
      public Integer getId(){
       return (Integer) get("id");
      }
     
      public void setId(Integer id){
       set("id", id);
      }
     
      public Integer geTaskId(){
       return (Integer) get("taskId");
      }
     
      public void setTaskId(Integer taskId){
       set("taskId", taskId);
      }
     
      public String getProject(){
       return (String) get("project");
      }
     
      public void setProject(String project){
       set("project", project);
      }
     
      public String getDue(){
       return (String) get("due");
      }
     
      public void setDue(String due){
       set("due", due);
      }
     
      public String getDescription(){
       return (String) get("description");
      }
     
      public void setDescription(String project){
       set("description", project);
      }
      public Double getEstimate() {
       return (Double) get("estimate");
      }
      public void setEstimate(double estimate){
       set("estimate", new Double(estimate));
      }
      public Double getRate() {
       return (Double) get("rate");
      }
      public void setRate(double rate) {
       set("rate", new Double(rate));
      }
     }
    }

  2. #2
    Ext User
    Join Date
    Sep 2008
    Location
    Germany
    Posts
    961
    Vote Rating
    1
      0  

    Default

    if you dont like the summary and the grouping you need also to exclude it.

    PHP Code:
    //        GroupSummaryView summary = new GroupSummaryView();
    //        summary.setForceFit(true);
    //        summary.setShowGroupedColumn(false);
    ...
    //        grid.setView(summary); 
    why? because if you use the GroupSummaryView which extends GroupingView it needs this field:

    PHP Code:
      protected void onRemove(ListStore<ModelDatadsModelData mint indexboolean isUpdate) {
        
    super.onRemove(dsmindexisUpdate);
        
    String groupField getGroupField();
        
    // line 408 from the error stack trace                   \/ \/ \/ \/                \/ \/ \/ \/   
        
    Element g XDOM.getElementById(getGroupId(grid.getId(), groupFieldgetGroup(m.get(groupField), mindex,
        
    //                                                       /\ /\ /\ /\                /\ /\ /\ /\ 
    This forum needs your help: you got hints from the community and now you have fixed your code? dont just reply with "now its fixed" or "i found the error"! please take the time to post also an detailed answer with the working code.

    GreaseMonkey Script for a GXT-only Forum: it hides ExtJs here: New Posts Search Results Advanced Search form Category overview http://www.extjs.com/forum/showthrea...041#post410041

  3. #3
    Sencha User
    Join Date
    Aug 2009
    Posts
    26
    Vote Rating
    0
      0  

    Default

    Thanks Arno.Nyhm.. you did it again !!..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •