Announcement

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

    Grouped filtering

    Hi, I am using ListGrids to display various information. I have noticed that the filters do no have any effect on the table if the data has been grouped. Is this a bug in the source, or is there actually a way of doing what I want to?

    Thanks

    #2
    Show us a sample in the showcase where you see this.

    Filtering works fine in this sample after grouping on continent.

    Post a minimal standalone testcase if you are still having issues.

    Comment


      #3
      Filters work for me when the ListGrid is grouped. But I am doing server side filtering, don't know if it works differently for client side filtering.

      Comment


        #4
        I believe I am doing client side filtering. I noticed that the samples were working, I also should have added that I am using the latest version for the trunk.

        All I am doing is retrieving the data from my server, the grid then only renders according to the drawAheadRatio value. However, I cannot group and filter at the same time.

        Is it possible that the trunk source may have a defect?

        Comment


          #5
          As stated previously :
          Originally posted by smartgwt.dev
          Post a minimal standalone testcase if you are still having issues.
          No one knows what you're doing without seeing your code. You can try to build from SVN and run the showcase sample if you want to test the sample against the trunk.
          Last edited by smartgwt.dev; 23 Sep 2009, 07:59.

          Comment


            #6
            Right, I am using the attached files from the following thread:
            http://forums.smartclient.com/showthread.php?t=4814&highlight=group

            The data is displayed in the grid fine. When filtering whilst there is no grouping the grid again behaves as expected. However, when filtering while there is a grouping, there is no effect. I have noticed that TransformRequest is called when a filter is applied (using DataSource.filterData()) but from there executeFetch() is called again.

            What can be done to implement the functionality I require?

            Comment


              #7
              Hi,
              I am trying to use the filter and group functionalities on a ListGrid but I don't understand why it doesn't work.

              The records inside the grid are displayed properly (well grouped), but the filter doesn't work. I use the standard filterEditor on the grid.

              I use the GwtRpcDataSource, and when the records are grouped, executeFetch() method is always called when I filter records. So it's normal the filter doesn't work in this case because executeFetch() call my service and retrive all the records...

              As soon as I disable the group functionality, executeFetch() is never called and the filter works properly.

              My ListGrid component
              Code:
              public class MyWidget extends CommonWidget {
              
              	private final MyServiceAsync myService = GWT.create(MyService.class);
              	
              	public MyWidget() {
              		
              		ListGridField field1 = new ListGridField("field1ColName");
              		field1.setType(ListGridFieldType.TEXT);
              		field1.setCanFilter(true);
              		field1.setCanEdit(false);
              		
              		ListGridField field2 = new ListGridField("field2ColName");
              		field2.setType(ListGridFieldType.INTEGER);
              		field2.setCanFilter(true);
              		field2.setCanEdit(false);
              		field2.setWidth(200);
              		field2.setSortDirection(SortDirection.DESCENDING);
              		
              		ListGridField field3 = new ListGridField("field3ColName");
              		field3.setType(ListGridFieldType.TEXT);
              		field3.setCanFilter(true);
              		field3.setCanEdit(false);
              		
              		ListGridField field4 = new ListGridField("field4ColName");
              		field4.setType(ListGridFieldType.TEXT);
              		field4.setCanFilter(true);
              		field4.setCanEdit(false);
              		
              		ListGridField field5 = new ListGridField("field5ColName");
              		field5.setType(ListGridFieldType.TIME);
              		DateTimeItem dateTimeEditorType = new DateTimeItem();
              		dateTimeEditorType.setDisplayFormat("yyyy-MM-dd-HH.mm.ss");
              		dateTimeEditorType.setUseTextField(true);
              		dateTimeEditorType.setUseMask(true);
              		dateTimeEditorType.setEnforceDate(true);
              		dateTimeEditorType.setCenturyThreshold(50);
              		field5.setEditorType(dateTimeEditorType);
              		field5.setCanFilter(false);
              		field5.setCellFormatter(getCellFormatter());
              		field5.setCanEdit(true);
              		field5.setWidth(120);
              		field5.setCanFilter(true);
              		
              		ListGridField field6 = new ListGridField("field6ColName");
              		field6.setCanFilter(false);
              		field6.setCanEdit(false);
              		field6.setWidth(100);
              		addIconInField(field6, this, Page.getSkinImgDir()+"actions/", ".png");
              		
              		ListGridField field7 = new ListGridField("field7ColName");
              		field7.setCanFilter(false);
              		field7.setCanEdit(false);
              		field7.setWidth(100);
              		addIconInField(field7, this, GWT.getModuleBaseURL() + "images/", ".gif");
              
              		grid.setID("myGridID");		
              		
              		grid.setDataSource(MyDS.getInstance());
              		
              		grid.setCanExpandRecords(true);
              		
              		grid.setEditEvent(ListGridEditEvent.CLICK);
              		
              		grid.setEditByCell(true);
              		
              		grid.setSortField(MyDS.NUDOSS_COL_NAME);
              		
              		grid.setGroupByField(MyDS.STATUS_COL_NAME);
              		
              		grid.setGroupStartOpen(GroupStartOpen.ALL);
              		
              		grid.setFields(field1, field2, field3, field4, field5, field6, field7);
              		
              		VStack layout = new VStack();
              		layout.setSize("100%", "100%");
              		layout.addMember(grid);
              		
              		addChild(layout);
              	}
              My Datasource
              Code:
              public class MyDS extends CommonDS {
              
              	private final MyServiceAsync myService = GWT.create(MyService.class);
              	
              	private static MyDS instance = null;
              	
              	public static MyDS getInstance() {
              
              		if (instance == null) {
              			instance = new MyDS("myDS");
              		}
              
              		return instance;
              	}
              
              	public MyDS(String datasourceId) {
              
              		setID(datasourceId);
              
              		DataSourceTextField field1 = new DataSourceTextField("field1ColName");
              		field1.setCanFilter(true);
              		field1.setCanEdit(false);
              		
              		DataSourceIntegerField field2 = new DataSourceIntegerField("field2ColName");
              		field2.setCanFilter(true);
              		field2.setCanEdit(false);
              		field2.setPrimaryKey(true);
              
              		DataSourceTextField field3 = new DataSourceTextField("field3ColName");
              		field3.setCanFilter(true);
              		field3.setCanEdit(false);
              
              		DataSourceTextField field4 = new DataSourceTextField("field4ColName");
              		field4.setCanFilter(true);
              		field4.setCanEdit(false);
              
              		DataSourceDateField field5 = new DataSourceDateField("field5ColName");
              		field5.setCanFilter(true);
              		field5.setCanEdit(true);
              		
              		setFields(field1, field2, field3, field4, field5);
              	}
              
              	@Override
              	protected void executeFetch(final String requestId, DSRequest request, final DSResponse response) {
              
              		myService.getData(new AsyncCallback<List<MyObject>>() {
              
              			public void onSuccess(List<MyObject> objects) {
              
              				if (objects != null) {
              
              					ListGridRecord[] records = new ListGridRecord[objects.size()];
              					int nbRecords = records.length;
              					for (int i = 0; i < nbRecords; i++) {
              						ListGridRecord record = new ListGridRecord();
              						copyValues(objects.get(i), record);
              						records[i] = record;
              					}
              
              					response.setData(records);
              					processResponse(requestId, response);
              				}
              			}
              
              			public void onFailure(Throwable error) {
              
              				response.setStatus(RPCResponse.STATUS_FAILURE);
              				processResponse(requestId, response);
              			}
              		});
              	}
              
              	private void copyValues(MyObject object, ListGridRecord record) {
              
              		...
              	}
              	
              	protected void executeUpdate(String requestId, DSRequest request, DSResponse response) {
              
              		...
              	}
              }
              The super class of my ListGrid class
              Code:
              public class CommonWidget extends Canvas {
              
              	protected ListGrid grid;
              	
              	public CommonWidget() {
              		
              		grid = new ListGrid() {
              			
              			protected Canvas getExpansionComponent(ListGridRecord record) {
              				
              				String recordStatus = record.getAttribute("status");
              
              				if(...) {
              					return new MyWidget1(record);
              				}
              				else if(...) {
              					return new MyWidget2(record);
              				}
              				else if(...) {
              					return new MyWidget3(record);
              				}
              				else {
              					return null;
              				}
              			}
              		};
              		
              		grid.setCanExpandRecords(false);
              		grid.setWidth100();
              		grid.setHeight100();
              		
              		grid.setShowAllRecords(false);
              		
              		grid.setCanResizeFields(true);
              		
              		grid.setShowEmptyMessage(true);
              		grid.setEmptyMessage(HRWidgetMessages.getMessage("noData"));
              		
              		grid.setAlternateRecordStyles(true);
              		
              		grid.setLoadingDataMessage(HRWidgetMessages.getMessage("loading ..."));
              		
              		grid.setShowFilterEditor(true);
              		
              		grid.setAutoFetchData(true);
              	}
              	
              	protected void addIconInField(ListGridField gridField, RecordClickHandler recordClickHandler, String imageURLPrefix, String imageURLSuffix) {
              		
              		gridField.setType(ListGridFieldType.IMAGE);
              		gridField.setAlign(Alignment.CENTER);
              		gridField.setImageURLPrefix(imageURLPrefix);
              		gridField.setImageURLSuffix(imageURLSuffix);
              		gridField.setImageWidth(16);
              		gridField.setImageHeight(16);
              		gridField.setCanSort(false);
              		gridField.addRecordClickHandler(recordClickHandler);
              	}
              	
              	protected CellFormatter getCellFormatter() {
              		
              		return new CellFormatter() {
              
              			public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
              				
              				if(value == null) {
              					return "";
              				}				
              				
              				Date dateValue = (Date)value;
              				
              				return DateTimeFormat.getFormat("yyyy-MM-dd-HH.mm.ss").format(dateValue);
              			}
              		};
              	}
              }

              The super class of my Datasource
              Code:
              public abstract class CommonDS extends GwtRpcDataSource {
              	
              	protected void addIconInField(DataSourceImageField dataSourceField, String imageURLPrefix) {
              		
              		dataSourceField.setImageWidth("16");
              		dataSourceField.setImageHeight("16");
              		dataSourceField.setImageURLPrefix(imageURLPrefix);
              	}
              	
              	@Override
              	protected void executeAdd(String requestId, DSRequest request, DSResponse response) {
              	}
              
              	@Override
              	protected void executeRemove(String requestId, DSRequest request, DSResponse response) {
              	}
              
              	@Override
              	protected void executeUpdate(String requestId, DSRequest request, DSResponse response) {
              	}
              }
              The GWTRPCDatasource
              Code:
              public abstract class GwtRpcDataSource extends DataSource {
              
              	/**
                   * Creates new data source which communicates with server by GWT RPC.
                   * It is normal server side SmartClient data source with data protocol
                   * set to <code>DSProtocol.CLIENTCUSTOM</code>("clientCustom" - natively
                   * supported by SmartClient but should be added to smartGWT) and with data
                   * format <code>DSDataFormat.CUSTOM</code>.
                   */
                  public GwtRpcDataSource() {
                      setDataProtocol(DSProtocol.CLIENTCUSTOM);
                      setDataFormat(DSDataFormat.CUSTOM);
                      setClientOnly(false);
                  }
              
                  /**
                   * Executes request to server.
                   *
                   * @param request <code>DSRequest</code> being processed.
                   * @return <code>Object</code> data from original request.
                   */
                  @Override
                  protected Object transformRequest(DSRequest request) {
                      String requestId = request.getRequestId();
                      DSResponse response = new DSResponse();
                      response.setAttribute("clientContext", request.getAttributeAsObject("clientContext"));
                      // Assume success
                      response.setStatus(0);
                      switch(request.getOperationType()) {
                          case FETCH: 
                              executeFetch(requestId, request, response);
                              break;
                          case ADD:
                              executeAdd(requestId, request, response);
                              break;
                          case UPDATE:
                              executeUpdate(requestId, request, response);
                              break;
                          case REMOVE:
                              executeRemove(requestId, request, response);
                              break;
                          default:
                              // Operation not implemented.
                              break;
                      }
                      return request.getData();
                  }
              
                  /**
                   * Executed on <code>FETCH</code> operation. <code>processResponse (requestId, response)</code>
                   * should be called when operation completes (either successful or failure).
                   *
                   * @param requestId <code>String</code> extracted from <code>DSRequest.getRequestId ()</code>.
                   * @param request <code>DSRequest</code> being processed.
                   * @param response <code>DSResponse</code>. <code>setData (list)</code> should be called on
                   *      successful execution of this method. <code>setStatus (&lt;0)</code> should be called
                   *      on failure.
                   */
                  protected abstract void executeFetch(String requestId, DSRequest request, DSResponse response);
              
                  /**
                   * Executed on <code>ADD</code> operation. <code>processResponse (requestId, response)</code>
                   * should be called when operation completes (either successful or failure).
                   *
                   * @param requestId <code>String</code> extracted from <code>DSRequest.getRequestId ()</code>.
                   * @param request <code>DSRequest</code> being processed. <code>request.getData ()</code>
                   *      contains record should be added.
                   * @param response <code>DSResponse</code>. <code>setData (list)</code> should be called on
                   *      successful execution of this method. Array should contain single element representing
                   *      added row. <code>setStatus (&lt;0)</code> should be called on failure.
                   */
                  protected abstract void executeAdd(String requestId, DSRequest request, DSResponse response);
              
                  /**
                   * Executed on <code>UPDATE</code> operation. <code>processResponse (requestId, response)</code>
                   * should be called when operation completes (either successful or failure).
                   *
                   * @param requestId <code>String</code> extracted from <code>DSRequest.getRequestId ()</code>.
                   * @param request <code>DSRequest</code> being processed. <code>request.getData ()</code>
                   *      contains record should be updated.
                   * @param response <code>DSResponse</code>. <code>setData (list)</code> should be called on
                   *      successful execution of this method. Array should contain single element representing
                   *      updated row. <code>setStatus (&lt;0)</code> should be called on failure.
                   */
                  protected abstract void executeUpdate(String requestId, DSRequest request, DSResponse response);
              
                  /**
                   * Executed on <code>REMOVE</code> operation. <code>processResponse (requestId, response)</code>
                   * should be called when operation completes (either successful or failure).
                   *
                   * @param requestId <code>String</code> extracted from <code>DSRequest.getRequestId ()</code>.
                   * @param request <code>DSRequest</code> being processed. <code>request.getData ()</code>
                   *      contains record should be removed.
                   * @param response <code>DSResponse</code>. <code>setData (list)</code> should be called on
                   *      successful execution of this method. Array should contain single element representing
                   *      removed row. <code>setStatus (&lt;0)</code> should be called on failure.
                   */
                  protected abstract void executeRemove(String requestId, DSRequest request, DSResponse response);
              }

              My environment :
              Firefox 3.5.11
              SmartGWT 2.2
              GWT 2.0.3


              Any help would be appreciate

              Thanks
              Last edited by Ju123; 8 Sep 2010, 01:28.

              Comment


                #8
                Is my last message enough clear ?
                What could I send you ?

                I tried to understand again but I don't have any clue...


                Thanks

                Comment


                  #9
                  same problem with me
                  i am using smartclient 7
                  when multiple grouping is given by
                  boundList.groupBy("col 1", "col 2");
                  the filtering is not working..because it is calling the fetch method againg and
                  retriving all the values.

                  i am using DMI to call fetch method. where serverlook up method is "new"

                  any help..

                  Comment


                    #10
                    smartgwt.dev, the example in the showcase works, but there is no programatic grouping. Rows are not grouped by default.
                    In addition there is no Datasource object used in this example.

                    Do you have any example that work using a Datasource ? because the problem is the call of executeFetch() method

                    Actually, the question is : why executeFetch() method is called when rows are grouped ?

                    Firefox 3.5.11
                    SmartGWT 2.2
                    GWT 2.0.3
                    Last edited by Ju123; 8 Sep 2010, 01:27.

                    Comment


                      #11
                      mhulsman, could you send us an example of your code to understand ?

                      I am doing client side filtering, maybe it's the problem ?

                      Thanks

                      Comment

                      Working...
                      X