Announcement

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

    CubeGrid - ListGridRecord[] vs DataSource

    I'm currently evaluating v4.0 power edition of SmartGWT.

    I got the CubeGrid (basic) example working with my own data. here's the ListGridRecord

    Code:
    public class CubeItem extends ListGridRecord {
    
        public static final String kid = "cellID";
        public static final String ip = "ips";
        public static final String url = "urls";
        public static final String hour = "hours";
        public static final String day = "days";
        public static final String value = "_value";
        public static final String contents = "contents";
        public static final String hilite = "_hilite";
        
        public CubeItem() {
        }
        
        public CubeItem(int id, String hour, String day, int value, String content, String ip, String url) {
            kid(id);
            hour(hour);
            day(day);
            value(value);
            contents(content);
            ip(ip);
            url(url);
        }
        // methods omitted
    }
    then I create my CubeItem array
    Code:
            DataSource ds = new CubeDs(CubeDs.idPrefix + SgwtUtils.getRandomPositiveInt());
            int cnt = 0;
            CubeItem[] data = new CubeItem[l.size()];
            for (MetaTestObj m : l) {
                CubeItem ci = new CubeItem(cnt, m.getHour(), m.getDay(), m.getUrlcount(), "url", m.getIp(), m.getUrl()); 
                ds.addData(ci);
                data[cnt] = ci;
                cnt++;
            }
    and create the cube as following:

    Code:
        private void createCube(CubeItem[] data, String[] rows, String[] cols, DataSource ds) {
            cubeGrid = new CubeGrid();
            if(SC.hasDrawing()) {  
                cubeGrid.setEnableCharting(true);  
            }
            cubeGrid.setCanMoveFacets(true);  
            cubeGrid.setWidth100();  
            cubeGrid.setHeight100();  
            cubeGrid.setHideEmptyFacetValues(true);  
            cubeGrid.setShowCellContextMenus(true);  
            cubeGrid.setAutoFetchData(false);
            if (data != null) {
                cubeGrid.setData(data);
            }
            cubeGrid.setColumnFacets(cols);
            cubeGrid.setRowFacets(rows);
            if (ds != null) {
                cubeGrid.setDataSource(ds);
                cubeGrid.fetchData();
            }
        }
    and add it to my Layout.

    When passing along an array it's showing the data, but when passing along a DataSource I get an error. The DataSource is defined as following:

    Code:
    public class CubeDs extends DataSource {
    
        public static final String idPrefix = "productRevenue";
        
        public CubeDs(final String id) {
            setID(id);
            DataSourceIntegerField k = new DataSourceIntegerField(CubeItem.kid);
            k.setPrimaryKey(true);
            k.setRequired(true);
            k.setHidden(true);
            k.setCanEdit(false);
            
            DataSourceTextField s = new DataSourceTextField(CubeItem.ip);
            s.setCanEdit(false);
            
            DataSourceTextField t = new DataSourceTextField(CubeItem.url);
            t.setCanEdit(false);
            
            DataSourceTextField r = new DataSourceTextField(CubeItem.day);
            r.setCanEdit(false);
            
            DataSourceTextField p = new DataSourceTextField(CubeItem.hour);
            p.setCanEdit(false);
            
            DataSourceTextField v = new DataSourceTextField(CubeItem.value);
            v.setCanEdit(false);
            
            DataSourceTextField c = new DataSourceTextField(CubeItem.contents);
            c.setCanEdit(false);
            
            setFields(k, s, t, r, p, v, c);
        	setClientOnly(true);
        	setAddGlobalId(false);
        }
    }
    the error I get is
    Code:
    (TypeError) @com.google.gwt.core.client.impl.Impl::apply(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)([JavaScript object(96), JavaScript object(72), JavaScript object(99)]): this.rowFields[i][0] is undefined
    I know I missed something, but am not able to find the problem

    #2
    Can you show runnable code for how you are setting this up with a DataSource? The details matter, and something minor could be misconfigured.

    Comment


      #3
      The DataSource is client only, the method
      Code:
      DataSource ds = new CubeDs(CubeDs.idPrefix + SgwtUtils.getRandomPositiveInt());
              int cnt = 0;
              CubeItem[] data = new CubeItem[l.size()];
              for (MetaTestObj m : l) {
                  CubeItem ci = new CubeItem(cnt, m.getHour(), m.getDay(), m.getUrlcount(), "url", m.getIp(), m.getUrl()); 
                  ds.addData(ci);
                  data[cnt] = ci;
                  cnt++;
              }
      creates a new DataSource and adds the items to it. then I just call createCube(...).

      The MetaTestObj is just something I get back from an RPC call.

      what other information do you need?

      Comment


        #4
        We need complete code, or we'll be unable to spot whatever detail you got wrong.

        See also the FAQ about why not to use GWT-RPC.

        Comment


          #5
          ok, I'll have to minimize my testapp though. thanks in advance

          and yes, i read it about gwt-rpc, but its working very well so far. the only alternative would possibly be REST, but I'll have to look into it

          Comment

          Working...
          X