Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » scout » Row filters of tables(How to ignore a row when row filters are applied?)
Row filters of tables [message #1234162] Tue, 21 January 2014 11:24 Go to next message
Rainer N. is currently offline Rainer N.Friend
Messages: 9
Registered: January 2014
Junior Member
Hi,

my intent is to add a row to a table which contains the column sum of every visible row.

To do so, I need to ignore this row when the row filters are applied. However, the corresponding methods are private and thus can't be overridden:

private void applyRowFiltersInternal() {
    for (ITableRow row : m_rows) {
      applyRowFiltersInternal((InternalTableRow) row);
    }
  }

  private void applyRowFiltersInternal(InternalTableRow row) {
    row.setFilterAcceptedInternal(true);
    if (m_rowFilters.size() > 0) {
      for (ITableRowFilter filter : m_rowFilters) {
        if (!filter.accept(row)) {
          row.setFilterAcceptedInternal(false);
          /*
           * ticket 95770
           */
          if (isSelectedRow(row)) {
            deselectRow(row);
          }
          break;
        }
      }
    }
  }


m_rows is private, too. Thus, I can't remove the row and add it later using this list. (If I remove the row using the methods, events will be fired and the newly added row does not appear (presumably because of the filtering Wink))

If I wanted to use custom row filters, I had to create filters for all different column types and I probably had to customize the ColumnFilterForm.

What other way is possible to achieve the desired behaviour?

(Besides, if possible, I would also like to skip the row when sorting the table.)

Thank you.

Best regards,
Rainer
Re: Row filters of tables [message #1234288 is a reply to message #1234162] Tue, 21 January 2014 16:13 Go to previous messageGo to next message
Matthias Otterbach is currently offline Matthias OtterbachFriend
Messages: 9
Registered: June 2013
Junior Member
Even though it might be difficult to overwrite the org.eclipse.scout.rt.client.ui.basic.table.AbstractTable.applyRowFilters() method, it might be possible to overwrite the org.eclipse.scout.rt.client.ui.basic.table.AbstractTable.getFilteredRows() method.

The new getFilteredRows() implementation could call the super method and check afterwards if the desired row is part of the results - if not it should add it.
Re: Row filters of tables [message #1234297 is a reply to message #1234162] Tue, 21 January 2014 16:27 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 817
Registered: October 2011
Senior Member
Rainer N. wrote on Tue, 21 January 2014 12:24

(Besides, if possible, I would also like to skip the row when sorting the table.)


Yes this is also possible.

You can add an additional column that is not displayable.
I will take an IntegerColumn as example: RowTypeIntegerColumn.

For all rows that represent your content you set the value to 0.
For the summary row (I assume you want it at the end) you set the value to 1.

On RowTypeIntegerColumn you set:
- Displayable: false.
- SortIndex: 1.
- AlwaysIncludeSortAtBegin: true.

This will ensure that the RowTypeIntegerColumn is considered for sorting before the columns that the user can define.

This pattern is not easy... I have it on my "missing documentation" list... If my message is not clear enough, do not hesitate to tell me.
Re: Row filters of tables [message #1234302 is a reply to message #1234297] Tue, 21 January 2014 16:35 Go to previous message
Rainer N. is currently offline Rainer N.Friend
Messages: 9
Registered: January 2014
Junior Member
@Matthias: Thank you very much, your proposed solution is working. Smile

Here is the code:
  @Override
  public ITableRow[] getFilteredRows() {
    ITableRow[] filteredRows = super.getFilteredRows();

    if (filteredRows.length > 0 && filteredRows[filteredRows.length - 1] != totalRow) {
      ITableRow[] result = new ITableRow[filteredRows.length + 1];
      System.arraycopy(filteredRows, 0, result, 0, filteredRows.length);
      result[filteredRows.length] = totalRow;
      return result;
    }
    else {
      return filteredRows;
    }
  }


@Jeremy: Thanks, that sounds good. I'll try it out.

Regards,
Rainer
Previous Topic:SWT product ignoring initial size and save and restore
Next Topic:REST service
Goto Forum:
  


Current Time: Fri Dec 19 21:56:28 GMT 2014

Powered by FUDForum. Page generated in 0.01856 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software