Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CDF-817] - Table component - search box doesn't work when "paginate … #201

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions core/src/main/java/pt/webdetails/cda/utils/TableModelUtils.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright 2002 - 2015 Webdetails, a Pentaho company. All rights reserved.
* Copyright 2002 - 2016 Webdetails, a Pentaho company. All rights reserved.
*
* This software was developed by Webdetails and is provided under the terms
* of the Mozilla Public License, Version 2.0, or any later version. You may not use
Expand Down Expand Up @@ -245,17 +245,27 @@ private static DataTableFilter getRowFilter( final QueryOptions queryOptions, fi
}

if ( searchableIndexes == null ) { //include all
searchableIndexes = new int[ outputIndexes.size() ];
for ( int i = 0; i < searchableIndexes.length; i++ ) {
searchableIndexes[ i ] = outputIndexes.get( i );
}
searchableIndexes = toIntArray( outputIndexes );
}

return new DataTableFilter( filterText, searchableIndexes );
}

for ( Parameter parameter:queryOptions.getParameters() ) {
if ( parameter.getName().equals( "searchBox" ) ) {
return new DataTableFilter( parameter.getStringValue(), toIntArray( outputIndexes ) );
}
}
return null;
}

private static int[] toIntArray( List<Integer> outputIndexes ) {
int [] searchableIndexes = new int[ outputIndexes.size() ];
for ( int i = 0; i < searchableIndexes.length; i++ ) {
searchableIndexes[ i ] = outputIndexes.get( i );
}
return searchableIndexes;
}

private static List<Integer> getOutputIndexes( final DataAccess dataAccess, final QueryOptions queryOptions,
TableModel table ) throws InvalidOutputIndexException {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright 2002 - 2015 Webdetails, a Pentaho company. All rights reserved.
* Copyright 2002 - 2016 Webdetails, a Pentaho company. All rights reserved.
*
* This software was developed by Webdetails and is provided under the terms
* of the Mozilla Public License, Version 2.0, or any later version. You may not use
Expand Down Expand Up @@ -130,8 +130,15 @@ public void testOutputIdx() throws Exception {
new Object[] { 2.0d, "two" } ), result );
checker.assertColumnNames( result, "c3", "c2" );
checker.assertColumnClasses( result, Double.class, String.class );
opts.addParameter( "searchBox", "one" );
result = TableModelUtils.postProcessTableModel( dataAccess, opts, tm );
checker = new TableModelChecker();
checker.assertEquals( new SimpleTableModel(
new Object[] { 1.0d, "one" } ), result );

when( dataAccess.getOutputMode( 6 ) ).thenReturn( OutputMode.EXCLUDE );
opts = new QueryOptions();
opts.setOutputIndexId( 6 );
result = TableModelUtils.postProcessTableModel( dataAccess, opts, tm );
checker.assertEquals(
new SimpleTableModel( new Object[] { 1L }, new Object[] { 2L } ),
Expand Down