How to set different filtering option

This forum is used by users to request and discuss new product features. Please do not use this forum for technical support including bug reports.

Moderator: JIDE Support

Forum rules
Product suggestions only. Please do not use this forum for technical support including bug reports.

How to set different filtering option

Postby pasalkarsachin1 » Mon Jul 01, 2013 7:10 am

Hi,

I have implemented FilterTableModel, which is passed to QuickFilterField and the model return by QuickFilterField is assigned to the JTable.

Now, my question is how to apply different filtering option (AND and OR) to FilterTableModel and QuickFilterField. I know that FilterTableModel has API setANDMode(). I want to filter out data from column drop down in AND mode and OR mode for QuickFilterField. Is this behavior possible?

Regards,
Sachin
pasalkarsachin1
 
Posts: 45
Joined: Fri May 11, 2012 5:54 am

Re: How to set different filtering option

Postby JIDE Support » Mon Jul 01, 2013 9:23 am

By default, QuickTableFilterField sets the And mode to false which means it is using OR mode for the FilterableTableModel. You can set it to And mode (and we will not change it back) but I am not quite sure how you plan to use it.
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37245
Joined: Sun Sep 14, 2003 10:49 am

Re: How to set different filtering option

Postby pasalkarsachin1 » Tue Jul 02, 2013 1:53 am

Hi,
Please see the below image for more clarification.
JIDE.png
JIDE.png (95.67 KiB) Viewed 36738 times


Code snippet:

this.vcfTable.setRowSelectionAllowed(true);
AutoFilterTableHeader header = new AutoFilterTableHeader(this.vcfTable);
header.setAllowMultipleValues(true);
header.setShowFilterIcon(true);
header.setAutoFilterEnabled(true);
header.setUseNativeHeaderRenderer(true);
header.setShowFilterNameAsToolTip(true);

this.vcfTable.setTableHeader(header);
FilterableTableModel tableModel= (FilterableTableModel) TableModelWrapperUtils.getActualTableModel(this.vcfTable.getModel(),FilterableTableModel.class);
tableModel.setAndMode(true);

this.filterField = new QuickTableFilterField(this.vcfTable.getModel()){

/**
*
*/
private static final long serialVersionUID = 1L;

@Override
protected JidePopupMenu createContextMenu() {

JidePopupMenu jidePopupMenu = super.createContextMenu();
VcfTableModel actualTableModel = (VcfTableModel)TableModelWrapperUtils.getActualTableModel(this.getTableModel(), VcfTableModel.class);
ArrayList<String> invisibleColumnNames = actualTableModel.getInvisibleColumnNames();
if(invisibleColumnNames!=null)
invisibleColumnNames=new ArrayList<String>();
for (Component component : jidePopupMenu.getComponents()) {

if(invisibleColumnNames.contains(component.getName()))
jidePopupMenu.remove(component);
}
return jidePopupMenu;
}

};

this.vcfTable.setModel(this.filterField.getDisplayTableModel());
this.filterField.setHintText(Messages.getMessage(IMessageKeys.TYPE_HERE_FOR_FILTER));
this.filterField.setShowMismatchColor(true);


Regards,
Sachin
pasalkarsachin1
 
Posts: 45
Joined: Fri May 11, 2012 5:54 am

Re: How to set different filtering option

Postby JIDE Support » Tue Jul 02, 2013 8:37 am

In this case, you just need two FilterableTableModel. The order is the actual model -> FilterableTableModel used by AFTH -> FilterableTableModel used by QTFF where "->" means wraps or you can consider the data flows from the inner mode to the outer model. The last QTFF FilterableTableModel is set to the table. The two FilterableTableModels will be in AND logic because one wraps the other (no need to call setAndMode). Right now because AFTT will reuse the FilterableTableModel if there is one which is causing the problem that only one FilterableTableModel is used in your code. To workaround it, just use the code below to replace the line which creates the AFTH.

Code: Select all
AutoFilterTableHeader header = new AutoFilterTableHeader(this.vcfTable) {
            @Override
            protected IFilterableTableModel createFilterableTableModel(TableModel model) {
                return new FilterableTableModel(model);
            }
        };

Please move the code from

Code: Select all
this.filterField = new QuickTableFilterField(this.vcfTable.getModel()){

to
Code: Select all
this.filterField.setShowMismatchColor(true);

to somewhere before

Code: Select all
AutoFilterTableHeader header = new AutoFilterTableHeader(this.vcfTable)
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37245
Joined: Sun Sep 14, 2003 10:49 am

Re: How to set different filtering option

Postby pasalkarsachin1 » Thu Jul 04, 2013 3:50 am

Hi,

Thanks a lot for above solution.

However, I have encountered one more problem. When I search using QTFF for numeric value, QTFF expects ','(comma) for the value(e.g. 1,078), whereas the value shown in table is 1078.

PFA for further clarification.

Regards,
Sachin
Attachments
Untitled.png
Untitled.png (48.26 KiB) Viewed 36729 times
pasalkarsachin1
 
Posts: 45
Joined: Fri May 11, 2012 5:54 am

Re: How to set different filtering option

Postby JIDE Support » Thu Jul 04, 2013 8:26 am

The JIDE Grids has a centralized ObjectConverterManager which takes care of all the value <-> string conversion. It looks like you didn't use this ObjectConverterManager in your table but we are using it in QTFF and AFTH. If you want a quick fix, you can call NumberConverter.setGroupingUsed(false). However a more elegant way is to for you to setup the ObjectConverterManager according to your need and let your table model implementing ContextSensitiveTableModel interface so that it will use the ObjectConverterManager too.
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37245
Joined: Sun Sep 14, 2003 10:49 am


Return to Product Suggestions

Who is online

Users browsing this forum: No registered users and 8 guests