Announcement

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

    CubeGrid doesn't visually show changes after calling cubegrid.addData(record)

    Hello,

    I have a CubeGrid and ListGrid that are both linked to the one same DataSource.

    When I call cubeGrid.addData(record), only the ListGrid visually shows changes.

    The cubeGrid however doesn't seem to show any visual changes.

    Code:
           CubeGrid cubeGrid = new CubeGrid();
           Vcm_datasourceDs vcmDS = new Vcm_datasourceDs();
    
            if(SC.hasDrawing()) {  
                cubeGrid.setEnableCharting(true);  
            } 
    
            cubeGrid.setCanAdaptHeight(true);
            cubeGrid.setCanAdaptWidth(true);
    
            vcmDS.waitUntilDsReady2(50, new DSReadyCallback() {
    
                @Override
                public void execute() {
    
                    cubeGrid.setDataSource(vcmDS.getDataSource());                
                    cubeGrid.setValueProperty("Value");
                    cubeGrid.setCellIdProperty("cellID");
                    cubeGrid.setRowFacets("Regions", "Products");
                    cubeGrid.setColumnFacets("Time");                
                    cubeGrid.fetchData();                
                    getThis().addMembers(cubeGrid);
                }
            });
    Code:
                //button that calls the addData(record) function
                IButton btnAdd = new IButton("Add Data", new ClickHandler() {
    
                @Override
                public void onClick(ClickEvent event) {
                    // TODO Auto-generated method stub
                    if (cubeGrid != null)
                    {
                        RecordList rl = cubeGrid.getDataAsRecordList();
                        int iAutoValue = rl.getLength();
    
                        Record recordAdd = new Record();
                        recordAdd.setAttribute("Regions", "GASES");
                        recordAdd.setAttribute("Products", "O2");
                        recordAdd.setAttribute("Time", String.valueOf(++iAutoValue));
                        recordAdd.setAttribute("Value", String.valueOf(++iAutoValue));
    
                        cubeGrid.addData(recordAdd);
    
                    }
                }
            });
    Hopefully the code snippet above are sufficient.

    The outcome in picture:
    Click image for larger version

Name:	cg.png
Views:	57
Size:	11.8 KB
ID:	252497

    #2
    CubeGrids will update automatically if a record that is shown in an existing cell is updated. It looks like you're expecting the auto-derived facetValues to be updated, rebuilding the headers of the cube - this won't happen automatically (by design) and requires a call to setData() if you actually want this behavior.

    Comment


      #3
      Yes, I would like to see the facetValues to be updated as well.

      The alternative, not-so-elegant solution that I have now is to call cubeGrid.destroy() and then calling the entire functions above from setDataSource() until fetchData() again.

      Regarding the setData(), the docs write:

      When calling setData(), if data is provided as a RecordList or ResultSet, direct changes to the list using Framework APIs such as RecordList.add() or RecordList.remove() will be automatically observed and the ListGrid will redraw in response.
      ...
      If this method is called after the component has been drawn/initialized: Provides a new data set to the ListGrid after the grid has been created or drawn. The ListGrid will redraw to show the new data automatically.
      The RecordList.add(record) increases the data as expected.

      However it seems like the functions that causes the redraw called from both RecordList.add() and setData() only applies to a ListGrid.

      Any idea how can I get the setData() to work with updating the facetValues here?

      Comment


        #4
        We're not quite sure what you're asking here.. we said to call setData(), did you try that and not have it work?

        Comment


          #5
          I did try to call setData().

          These are the codes right before the cubeGrid is drawn:

          Code:
                   vcmDS.waitUntilDsReady2(500, new DSReadyCallback() {
          
                      @Override
                      public void execute() {
                          // TODO Auto-generated method stub
                          vcmDS.getDataSource().fetchData(null, new DSCallback() {
          
                              @Override
                              public void execute(DSResponse dsResponse, Object data, DSRequest dsRequest) {
                                  // TODO Auto-generated method stub    
                                  cubeGrid.setDataSource(vcmDS.getDataSource());                        
                                  RecordList rl = dsResponse.getDataAsRecordList();                    
                                  cubeGrid.[B]setData[/B](rl);                        
                                  cubeGrid.setValueProperty("Value");
                                  cubeGrid.setCellIdProperty("cellID");
                                  cubeGrid.setHiliteProperty("_hilite");  
                                  cubeGrid.setRowFacets("Regions", "Products");
                                  cubeGrid.setColumnFacets("Time");    
                                  getThis().addMembers(cubeGrid); //VLayout object adds cubeGrid
                              }
                          });
                      }
                  });
          Then I tried calling setData() again in a simple addData() function below, since according to the docs the ListGrid (in my case a cubeGrid) should redraw after calling setData() to show the new data immediately.

          Code:
          IButton btnAdd = new IButton("Add Data", new ClickHandler() {
          
          @Override
          public void onClick(ClickEvent event) {
              // TODO Auto-generated method stub
          if (cubeGrid != null)
          {
              Record recordAdd = new Record();
              recordAdd.setAttribute("Regions", "GASES");
              recordAdd.setAttribute("Products", "O2");
              recordAdd.setAttribute("Time", "testTime");
              recordAdd.setAttribute("Value", "testValue");
          
             RecordList rl2 = cubeGrid.getDataAsRecordList();
             rl2.add(recordAdd);
          
             cubeGrid.[B]setData[/B](rl2);
             listGridTest.[B]setData[/B](rl2);
          }
          }
          });
          The ListGrid (listGridTest) did reflect visual changes, but the cubeGrid didn't.

          Comment


            #6
            It looks like you are not specifying facetValues for each facet, but instead relying on the values being auto-derived from the data. Currently, this process isn't repeated if you just call setData(), as what actually needs to be updated is each facet's facet.values, and also it would be undesirable for setData() to always re-run this process (for example, if all one wanted to change was currently visible cell values).

            Since re-deriving the set of facet.values from the data is a full rebuild of the cube (the entire header structure may change, so there's no good way to do it incrementally), you may as well simple use new CubeGrid() to do this.

            We may, in the future, add APIs that allow an incremental change in cases where, for example, a single record is being added, which introduces just a single new header.

            Comment


              #7
              Thank you, Isomorphic

              Comment

              Working...
              X