Announcement

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

    CubeGrid facet click handler

    How can I detect when a user clicks on a facet in the CubeGrid with SmartGWTEE?

    With Smartclient 8, there is facetValueSelectionChanged, which works well for me. But when using the nightly build from June 15 of SmartGWTEE 2.5, there is no corresponding method.

    Smartclient version:
    Code:
    myCube = isc.CubeGrid.create({
    	data:incomingData,
    	width:700,
    	height:700, 
        	hideEmptyFacetValues:false,
    	wrapFacetTitle:true,
    	canReorderColumns:false,
    	defaultFacetWidth:60,
    	formatCellValue:"isc.Format.toUSString(value)",
    	canSelectHeaders:true,
    	facetValueSelectionChanged:facetClicked,
    	columnFacets:["day","name"],
    	rowFacets:["stat"],
    	position:"relative"
    });
    
    function facetClicked(clickedFacet) {
            console.log(clickedFacet);
    }
    SmartGWTEE 2.5 version:
    Code:
    final VLayout everything = new VLayout();
    dataSource.fetchData(c, new DSCallback() {
    @Override
    public void execute(DSResponse response, Object rawData, DSRequest request) {
    final CubeGrid cubeGrid2 = new CubeGrid();
    	cubeGrid2.setData(response.getData());
    	cubeGrid2.setWidth100();
    	cubeGrid2.setHeight100();
    	cubeGrid2.setHideEmptyFacetValues(true);	
    	cubeGrid2.setShowCellContextMenus(true);
    	cubeGrid2.setColumnFacets("day","name");
    	cubeGrid2.setRowFacets("stat");
    	
    	final NumberFormat numberFormat = NumberFormat.getFormat("###,###,###,###");
    	
    	cubeGrid2.setCellFormatter(new CellFormatter() {
    	
    	public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
    		if (value == null) return null;
    		try {
    			return numberFormat.format(((Number) value).longValue());
    		} catch (Exception e) {
    			return value.toString();
    		}
    	}
    	});
    			              
    	//this only works if you click a cell inside the grid, not on the facet title.
    	cubeGrid2.addCellClickHandler(new CellClickHandler() {
    		@Override
    		public void onCellClick(CellClickEvent event) {
    			SC.say("first handler");	
    		}
    	});
    		
    	//this never seems to fire	              
            cubeGrid2.addSelectionChangedHandler(new SelectionChangedHandler() {
    
    		@Override
    		public void onSelectionChanged(SelectionEvent event) {
    			SC.say("second handler");
    		}
    	});
    			              
     	everything.addMember(cubeGrid2);
    }
    });

    #2
    It hasn't been added yet (there are a number of event handlers still to be added). What do you need it for in this case (there might be other approaches)?

    Comment


      #3
      Ok, that makes sense. I kept thinking I was missing something.

      When a user clicks on a row facet, I want to load only that row's data in a chart. I know about the context menu charting feature, but I want the chart on the screen at all times.

      Bart

      Comment


        #4
        I have the same problem. Was a solution ever found to this?

        Thanks,
        Aaron

        Comment


          #5
          my solution

          I just use workaround for this problem.

          Add to the CubeGrid definition:

          facetValueOut: function(facetValue) {
          selectedFacet=null
          },

          facetValueOver: function(facetValue) {
          selectedFacet=facetValue["facetId"];
          },
          click: function() {
          if (selectedFacet != null) {
          alert(selectedFacet);
          }
          return true;
          },

          Comment

          Working...
          X