Skip to content

Commit

Permalink
[CDF-817] - Table component - search box doesn't work when "paginate …
Browse files Browse the repository at this point in the history
…server side" is set to true
  • Loading branch information
Elio Freitas committed Mar 29, 2016
1 parent 39caa8c commit 251dfa6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
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

0 comments on commit 251dfa6

Please sign in to comment.