Announcement

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

    Simple Cube Grid Auto Sizing within Window / Layout

    I've tried to get a Window layout to draw and automatically size a Cube Grid, with no success for days. Yes I have read a lot of documentation, but fail to see where the problem lies. While this is not a simple standalone code sample, I'm confident you will be able to diagnose my fault.
    Code:
                      final CubeGrid dvdCube = new CubeGrid();
                        com.smartgwt.client.widgets.Window dvdWin = new com.smartgwt.client.widgets.Window();
    
                        dvdCube.setHideEmptyFacetValues(true);
                        dvdCube.setColumnFacets("Mode", "Category", "Corner");
                        dvdCube.setRowFacets("Status","VBin");
                        dvdCube.setValueProperty("_value");
    
                        List<ListGridRecord> dvdD = new ArrayList<ListGridRecord>();
    
         // this is a simple static convenience method for loading example data.  It works fine.
    
                        dvdD.add(CubeGridConfig.setCubeGridDVDData("Max", "Standard", "ff069125", "0.00::0.01", "Completed", 0));
                        dvdD.add(CubeGridConfig.setCubeGridDVDData("Max", "Standard", "ff069125", "0.01::0.02", "Completed", 7));
                        dvdD.add(CubeGridConfig.setCubeGridDVDData("Max", "Standard", "ff069125", "0.02::0.03", "Completed", 10));
                        dvdD.add(CubeGridConfig.setCubeGridDVDData("Max", "Standard", "ff069125", "0.03::0.04", "Completed", 30));
                        dvdD.add(CubeGridConfig.setCubeGridDVDData("Max", "Standard", "ff069125", "0.05::0.06", "Completed", 800));
                        dvdD.add(CubeGridConfig.setCubeGridDVDData("Max", "Standard", "ff069125", "0.06::0.07", "Completed", 0));
                        dvdD.add(CubeGridConfig.setCubeGridDVDData("Max", "Special", "ff069125", "0.00::0.01", "Completed", 4));
                        dvdD.add(CubeGridConfig.setCubeGridDVDData("Max", "Special", "ff069125", "0.01::0.02", "Completed", 0));
                        dvdD.add(CubeGridConfig.setCubeGridDVDData("Max", "Special", "ff069125", "0.02::0.03", "Completed", 10));
                        dvdD.add(CubeGridConfig.setCubeGridDVDData("Max", "Special", "ff069125", "0.03::0.04", "Completed", 30));
                        dvdD.add(CubeGridConfig.setCubeGridDVDData("Max", "Special", "ff069125", "0.05::0.06", "Completed", 1000));
                        dvdD.add(CubeGridConfig.setCubeGridDVDData("Max", "Special", "ff069125", "0.06::0.07", "Completed", 0));
                        dvdD.add(CubeGridConfig.setCubeGridDVDData("Max", "Standard", "ss077125", "0.00::0.01", "Completed", 8));
                        dvdD.add(CubeGridConfig.setCubeGridDVDData("Max", "Standard", "ss077125", "0.01::0.02", "Completed", 0));
                        dvdD.add(CubeGridConfig.setCubeGridDVDData("Max", "Standard", "ss077125", "0.02::0.03", "Completed", 10));
                        dvdD.add(CubeGridConfig.setCubeGridDVDData("Max", "Standard", "ss077125", "0.03::0.04", "Completed", 20));
                        dvdD.add(CubeGridConfig.setCubeGridDVDData("Max", "Standard", "ss077125", "0.05::0.06", "Completed", 900));
                        dvdD.add(CubeGridConfig.setCubeGridDVDData("Max", "Standard", "ss077125", "0.06::0.07", "Completed", 0));
                        dvdD.add(CubeGridConfig.setCubeGridDVDData("Max", "Special", "ss077125", "0.00::0.01", "Completed", 9));
                        dvdD.add(CubeGridConfig.setCubeGridDVDData("Max", "Special", "ss077125", "0.01::0.02", "Completed", 0));
                        dvdD.add(CubeGridConfig.setCubeGridDVDData("Max", "Special", "ss077125", "0.02::0.03", "Completed", 10));
                        dvdD.add(CubeGridConfig.setCubeGridDVDData("Max", "Special", "ss077125", "0.03::0.04", "Completed", 30));
                        dvdD.add(CubeGridConfig.setCubeGridDVDData("Max", "Special", "ss077125", "0.05::0.06", "Completed", 1220));
                        dvdD.add(CubeGridConfig.setCubeGridDVDData("Max", "Special", "ss077125", "0.06::0.07", "Completed", 0));
    
                        dvdD.add(CubeGridConfig.setCubeGridDVDData("Pwr_Opt", "Standard", "ff069125", "0.00::0.01", "Completed", 0));
                        dvdD.add(CubeGridConfig.setCubeGridDVDData("Pwr_Opt", "Standard", "ff069125", "0.01::0.02", "Completed", 4));
                        dvdD.add(CubeGridConfig.setCubeGridDVDData("Pwr_Opt", "Standard", "ff069125", "0.02::0.03", "Completed", 10));
                        dvdD.add(CubeGridConfig.setCubeGridDVDData("Pwr_Opt", "Standard", "ff069125", "0.03::0.04", "Completed", 330));
                        dvdD.add(CubeGridConfig.setCubeGridDVDData("Pwr_Opt", "Standard", "ff069125", "0.05::0.06", "Completed", 900));
                        dvdD.add(CubeGridConfig.setCubeGridDVDData("Pwr_Opt", "Standard", "ff069125", "0.06::0.07", "Completed", 0));
                        dvdD.add(CubeGridConfig.setCubeGridDVDData("Pwr_Opt", "Special", "ff069125", "0.00::0.01", "Completed", 3));
                        dvdD.add(CubeGridConfig.setCubeGridDVDData("Pwr_Opt", "Special", "ff069125", "0.01::0.02", "Completed", 0));
                        dvdD.add(CubeGridConfig.setCubeGridDVDData("Pwr_Opt", "Special", "ff069125", "0.02::0.03", "Completed", 10));
                        dvdD.add(CubeGridConfig.setCubeGridDVDData("Pwr_Opt", "Special", "ff069125", "0.03::0.04", "Completed", 30));
                        dvdD.add(CubeGridConfig.setCubeGridDVDData("Pwr_Opt", "Special", "ff069125", "0.05::0.06", "Completed", 1230));
                        dvdD.add(CubeGridConfig.setCubeGridDVDData("Pwr_Opt", "Special", "ff069125", "0.06::0.07", "Completed", 0));
                        dvdD.add(CubeGridConfig.setCubeGridDVDData("Pwr_Opt", "Standard", "ss077125", "0.00::0.01", "Completed", 40));
                        dvdD.add(CubeGridConfig.setCubeGridDVDData("Pwr_Opt", "Standard", "ss077125", "0.01::0.02", "Completed", 0));
                        dvdD.add(CubeGridConfig.setCubeGridDVDData("Pwr_Opt", "Standard", "ss077125", "0.02::0.03", "Completed", 10));
                        dvdD.add(CubeGridConfig.setCubeGridDVDData("Pwr_Opt", "Standard", "ss077125", "0.03::0.04", "Completed", 30));
                        dvdD.add(CubeGridConfig.setCubeGridDVDData("Pwr_Opt", "Standard", "ss077125", "0.05::0.06", "Completed", 700));
                        dvdD.add(CubeGridConfig.setCubeGridDVDData("Pwr_Opt", "Standard", "ss077125", "0.06::0.07", "Completed", 10));
                        dvdD.add(CubeGridConfig.setCubeGridDVDData("Pwr_Opt", "Special", "ss077125", "0.00::0.01", "Completed", 20));
                        dvdD.add(CubeGridConfig.setCubeGridDVDData("Pwr_Opt", "Special", "ss077125", "0.01::0.02", "Completed", 0));
                        dvdD.add(CubeGridConfig.setCubeGridDVDData("Pwr_Opt", "Special", "ss077125", "0.02::0.03", "Completed", 10));
                        dvdD.add(CubeGridConfig.setCubeGridDVDData("Pwr_Opt", "Special", "ss077125", "0.03::0.04", "Completed", 30));
                        dvdD.add(CubeGridConfig.setCubeGridDVDData("Pwr_Opt", "Special", "ss077125", "0.05::0.06", "Completed", 1000));
                        dvdD.add(CubeGridConfig.setCubeGridDVDData("Pwr_Opt", "Special", "ss077125", "0.06::0.07", "Completed", 0));
    
    
                        dvdCube.setData(dvdD.toArray( new ListGridRecord[ dvdD.size() ] ));
                        dvdCube.setWidth100();
                        dvdCube.setHeight100();
                        dvdCube.setOverflow(Overflow.VISIBLE);
    
    
                        dvdWin.setAutoWidth();
                        dvdWin.setAutoHeight();
                        dvdWin.setOverflow(Overflow.VISIBLE);
                        dvdWin.setMargin(20);
                        dvdWin.setAutoCenter(true);
                        dvdWin.addMember(dvdCube);
                        dvdWin.draw();
    The result of this is a popup window of small size, with the Cube Grid shrunk to having vertical and horizontal scroll bars, and not fitting in the dvdWin Layout. What I want is a popup Window that fits the entire Cube Grid within it. Automatically sized.

    I'm basing this on the simple https://smartclient.com/smartgwtee/showcase/#cube_basic example

    What am I doing wrong?

    #2
    The main problem is that you are trying to get two things to "auto-size" to each other, without giving any size information to either one.

    The CubeGrid has no "natural size" - all of its interior elements can scroll, so it can fit whatever size you want, and just scrolls to show data as necessary.

    So you can either:

    1. give a size to the CubeGrid, and then set the window to autoSize:true (get rid of your attempts to manipulate overflow directly)

    OR

    2. give a size to the Window, and tell the CubeGrid to fill that (width/height 100%)

    Since this seems to be a pop-up Window, we would probably just give it width:85% height:85% with a maxHeight/maxHeight that ensure that doesn't become ridiculous on large screens, and the CubeGrid will fill that space and scroll as needed for larger datasets.

    Note that you might want to perfectly fit the Window to the CubeGrid when the dataset happens to be small enough to fit the user's current screen. Auto-fitting to data is not an available mode of the CubeGrid because, in most cases, the CubeGrid deals with a datacube with billions of elements, so you'd simply run out of memory and/or bury your DB with a ridiculously large request (in load on demand mode).

    If you really want to perfectly "shrink-wrap" the cube with the Window, and if you're sure the data is always small, you can calculate the width as just (number of row facets + number of distinct inner column headers) * 100.

    If this is a common use case, you could make that a utility method or use Feature Sponsorship to get some auto-sizing behaviors added to CubeGrid, for tiny cubes.


    Comment


      #3
      Thanks, makes sense.

      I guess I will have to reconsider which way I should approach this. I may change it into a List Grid with multiple levels of head spanning (more than 2).

      Comment


        #4
        Up to you, but that drops some features you might want (pivot, etc) and it seems like you may already have implemented a working data delivery mechanism to the cube.

        You are just a couple of easy settings away from fitting the cube in the window with scrolling as needed, and implementing a perfect shrinkwrap looks to be less code that reformatting your code for the ListGrid.

        Comment


          #5
          Something occurred to me in the past couple of days.

          Why does the example at https://smartclient.com/smartgwtee/showcase/#cube_basic , apparently not set a size, or min max size, of the parent canvas? I think that example led me to waste a couple of days in fruitless effort to auto size the cube grid. Is it misleading or am I missing how and where the canvas is sized? Is it the child cube grid sizing the parent VLayout? What am I missing?

          Asking in case others run into the same misinterpretation of the example.

          Comment


            #6
            Hi tece321,

            the CubeGrid is set to 100%:
            Code:
            cubeGrid.setWidth100();
            cubeGrid.setHeight100();
            But it does not need the size, because there is not enough data. Try to resize the columns to a much bigger size and you'll see scrolling introduced.

            Not sure if this helps?

            Best regards
            Blama

            Comment

            Working...
            X