Subscribe Bookmark RSS Feed

Data Filter only by columns that are of type 'character'

JimPappas

Occasional Contributor

Joined:

Nov 2, 2016

col_name_list_character=dt << Get Column Names("Character");

//  would like (if possible) to only filter by columns of type character. 
// Same as filtering by col_name_list_character above
//
Button Box( " Activate Filter ", dfilter = dt << data filter( Mode( Show( 1 ), Include( 1 ) ), add filter() ) ), 
//
// right now, the filter box has all columns (numeric and character)

I am having a hard time figuring out how to create a data filter within my application that ONLY filters by columns of type 'character'.  A small portion of my code is attached.   Seems like this one should be easy, but I'm obviously missing something.  Any help is appreciated!  

1 ACCEPTED SOLUTION

Accepted Solutions
Phil_Brown

Super User

Joined:

Mar 20, 2012

Solution

Hi @JimPappas

 

 

Try this:

 

Button Box( " Activate Filter ",
 	dfilter = dt << data filter( Mode( Show( 1 ), Include( 1 ) ), add filter() );
 	colObjList = {};
	For( i=1, i<=NItems(col_name_list_chacter), i++,
  		InsertInto(colObjList, Column(col_name_list_chacter[i]) );
 	);
 	Eval(EvalExpr( dfilter << columns( Expr(colObjList) ) ) );
       dfilter << Display( Single Category Display );

);

Note the "global" application of the option as you correctly described is achieved by apply the << Display( Single Category Display ) to the Data Filter Object, rather than each column

PDB
5 REPLIES
Phil_Brown

Super User

Joined:

Mar 20, 2012

@JimPappas

Try adding:

Button Box( " Activate Filter ",
  dfilter = dt << data filter( Mode( Show( 1 ), Include( 1 ) ), add filter() );
  colObjList = {};
For( i=1, i<=NItems(col_name_list_chacter), i++,
   InsertInto(colObjList, Column(col_name_list_chacter[i]) );
  );
  Eval(EvalExpr( dfilter << columns( Expr(colObjList) ) ) );
);

 

PDB
JimPappas

Occasional Contributor

Joined:

Nov 2, 2016

That works great - I really appreciate the response!

The only issue is that all the options / levels are showing for each column.  So the filter list goes way off the bottom of the page.  I can manually solve this AFTER the filter shows up on the screen (Display Options >  Single Category Display) but am having difficulty adding this to the code.   I can do this for each column (ex.  Display( :Operator, Single Category Display ) but don't know how to "globally" do this on each column since the columns change from dataset to dataset.   

 

Any advice on that one?

Phil_Brown

Super User

Joined:

Mar 20, 2012

Solution

Hi @JimPappas

 

 

Try this:

 

Button Box( " Activate Filter ",
 	dfilter = dt << data filter( Mode( Show( 1 ), Include( 1 ) ), add filter() );
 	colObjList = {};
	For( i=1, i<=NItems(col_name_list_chacter), i++,
  		InsertInto(colObjList, Column(col_name_list_chacter[i]) );
 	);
 	Eval(EvalExpr( dfilter << columns( Expr(colObjList) ) ) );
       dfilter << Display( Single Category Display );

);

Note the "global" application of the option as you correctly described is achieved by apply the << Display( Single Category Display ) to the Data Filter Object, rather than each column

PDB
JimPappas

Occasional Contributor

Joined:

Nov 2, 2016

That works great!   Thank you so much. 

Phil_Brown

Super User

Joined:

Mar 20, 2012

You're very welcome!
PDB