how to add a radio button filter for a grid?

hello, just started using ScriptCase, and I was wondering how can I achieve this.
I have a grid application, that displays some data, each table entry has a column called “state”, of type BIT, and its values can be 0, 1, or 2.

I want at the top of my grid, 3 radio buttons with the options : all (0), active (1), inactive (2).

So when I choose one of them, it’s going to filter the entries showed in the grid based on the “state” property.

How can I achieve this?

From what I understand, I need a control application, and then link this control in my grid application, but I didn’t manage to do it, so can someone guide me step by step?

Thank you

so I managed to solve this,
I created a Control application, with a radio button, then saved that radio button in a global variable,

then I used that global variable in my grid application with a Switch function, to change the statement I use in WHERE, so I can filter the data in the grid.

I have one more question, currently, in my Grid toolbar, there is a button called Filter, that is linked to my Control application, when clicked, it will open a modal with my 3 radio buttons

IS there a way to directly display the radio buttons on my Grid app? And not link them to a button, that is placed in the Grid Toolbar?

So I basically want my radio buttons directly displayed in my grid

hello, firstly thank you for the answer!

How would that help me? I tried displaying the search iframe above my grid, it works, but it’s just a search iframe, what I need is a 3 radio button (open, closed, all) as the purpose is, when choosing a radio option, it will filter the grid entries based on their status attribute (open, closed)

How can I achieve this with the activation of Search like you suggested?

ok maybe I understood what you meant,

enable the Search as initial app, and from the Search box above my grid, that now appears, remove all fields and create a new one, of type Radio,
then make 3 manual lookup value, 0, 1 and 2.

Now what I am missing, is how to pass those radio values to my grid??

the field name is ‘Filter’, so I tried on the event of the search (onFilterInit, onFilterRefresh, onFilterSave, onFilterValidate) to put something like:

[globVarFilter] = {Filter},

then in my grid events, in onApplicationInit: [StatusFilter] = [globVarFilter];
and then on onScriptInit:

switch ([StatusFilter]) {
case 0:
[ItemFilter] = “TblItem.ItemClosed = 0”;
break;
case 1:
[ItemFilter] = “TblItem.ItemClosed = 1”;
break;
case 2:
[ItemFilter] = “TblItem.ItemClosed < 2”;
break;
}

but nothing happens, so I guess that the global variable declared in the Search events doesnt work properly!

This is the same setup I have currently with my Control app, I declare a global there on the radio buttons, and pass it here on my grid, the only difference is, on my Control app, being a modal linked to a button in my Grid, I have put this line in the onValidateSuccess: sc_redir(business, filterClosedOpen={open}, “_parent”);
so it redirects to my Grid app, and takes the Radio field into a global variable : filterClosedOpen

What do I need to do to pass the Search variable to my grid ?

ok I solved this by just adding a code in onScriptInit

switch ({Filter}) {
case 0:
sc_select_where(add) = " AND TblItem.ItemClosed = 0";
break;
case 1:
sc_select_where(add) = " AND TblItem.ItemClosed = 1";
break;
case 2:
sc_select_where(add) = " AND TblItem.ItemClosed < 2";
break;
}

and {Filter} is the field I created in my Search module!
Works correctly!

yes that s exactly how I did it, but as my Table parameter to filter is a BIT, it can be 0 or 1, my radio buttons have 3 options, 0, 1 and <2 to show all, so for that I think the only way was to add the code above in the onScriptInit, so I can put a custom WHERE clause in my SQL

to show all records just set ‘DISPLAY TITLE’ in lookup. Then you will see a third radiobutton (see my example the first radiobutton no label). If you want label just add txt after DISPLAY TITLE