35
Views
12
Comments
Solved
[OutSystems Data Grid] OutSystemsDataGrid - Is it possible to filter when auto generating the collumns?
data-grid-reactive
Reactive icon
Forge component by Gonçalo Martins
Application Type
Reactive

I would like to have the option to save filters that I use in the OutSystems data grid. When using the filterbyvalue in this extension a ColumnWidgetId is required. But because the grid is auto generating the collumns I don't have such an id, just a binding. Is there any way to re-use filters that I created when using the grid?

Thanks in advance.

Solution

Hello @Aart van Blitterswijk 

After looking at your code I was able to understand the problem.

Basically, if you're trying to send a JSON generated to an auto-generated Grid without using the Arrange Data server action (which is an accelerator we provide), you won't have the metadata needed to allow the library to infer the data type (without using the column blocks the responsibility of preparing the data goes to the developer), so in that case the underlying library (Wijmo Flexgrid) will consider all the unknown information as text fields. and, for the particular case, you won't have all the information needed in the Js Grid object to apply the filter API (I tested using the Arrange data and passing the binding and it works).

Given the fact you're doing the JSON dynamically, you can try to use the action "buildJSONForGrid", from @Dorine Boudry forge component Data Workshop, where she's adding the metadata to the data, so the grid can understand what each column's data type is. 

This is the same issue mentioned here.

Hope it helps.

Cheers,
GM


Champion

Why you don't use the event OnFilterChange?

You have examples in the sample of component.

I am in fact using that, but because I'm using the auto generate collumns it doesn't give me a CollumnWidgetId. As it is also described in the ColumnWidgetId of the activeFiltersList structure.

Hi @Aart van Blitterswijk 

Can you please share a working example of your particular use case?
That way it would be easier to help since I think you can achieve that using custom code since the APIs can also use the bindings instead of the identifiers.

Cheers,
GM



Hi Goncalo,

See attached a simplified version of my problem. In the real eSpace I need the advanced sql to json because the sql is built dynamically from different tables each time. In the filter button action I am using a binding that is shown in the filter list. As you can test that is not working. Thanks in advance for looking into it.

SandboxAart.oml
Solution

Hello @Aart van Blitterswijk 

After looking at your code I was able to understand the problem.

Basically, if you're trying to send a JSON generated to an auto-generated Grid without using the Arrange Data server action (which is an accelerator we provide), you won't have the metadata needed to allow the library to infer the data type (without using the column blocks the responsibility of preparing the data goes to the developer), so in that case the underlying library (Wijmo Flexgrid) will consider all the unknown information as text fields. and, for the particular case, you won't have all the information needed in the Js Grid object to apply the filter API (I tested using the Arrange data and passing the binding and it works).

Given the fact you're doing the JSON dynamically, you can try to use the action "buildJSONForGrid", from @Dorine Boudry forge component Data Workshop, where she's adding the metadata to the data, so the grid can understand what each column's data type is. 

This is the same issue mentioned here.

Hope it helps.

Cheers,
GM


Hi Goncalo, I tried using the arrange data server action, but I get the error "Cannot create proxy with a non-object as target or handler ". I did not use buildJSONForGrid yet, but reading your comment I don't think you did either. Any ideas?

Edit: I think may be the Arrange data action needs a structure instead of a json in text format is that correct? If that's the case I probably can not use this, because the structure coming back from my query will be different for each report I'm building. This is because the user can select the entities that are used in the query.

As mentioned,  if you're trying to send a JSON generated to an auto-generated Grid that will mean you'll not be able to use the ArrangeData (and yes, it receives a structure list as an object), you'll need to add the metadata needed manually or using the forge component with buildJSONForGrid.

Hi Goncalo, thanks a lot for your help. Last week I was at ONE conference so it took a little longer, but it seems to be working now!

Hi @Aart van Blitterswijk ,

An approach I once thought about applying, is to use the GetViewLayout and SetViewLayout actions.  

If you create a structure matching the 'config' input/output of those actions, you could serialize/deserialize, pick it apart and save / restore the parts of it that you are interested in (like in this case the filter). 

For restoring completely and unaltered, you wouldn't even have to deserialize into a structure, just save the output config of GetViewLayout, and use it later with SetViewLayout.  I had a quick try, and that works, but I haven't tried to actually decompose and analyse the config.  The only thing that doesn't get remembered, is any search word used while setting a filter of type 'value', that's not part of the config, only the actual values that were selected.

Dorine

Hi Dorine, thanks so much for the reply. I have done a simple test and it works. This seems at least like a valid option if the report does not change. I will work a little bit with Goncalo's comments to see if I can get a little bit more control, but thanks for this solution already.

Champion

Hello

You can save the grid layout to the Database table and you can list down the saved layouts of table and you can apply the layout 

As @Dorine mentioned you can use GetViewLayout and SetViewLayout actions.   

I have created a demo for you that will help you with this-

Sample - https://personal-ejuytnht.outsystemscloud.com/Filters/Grid

I hope this will help you,

Best Regards
Tousif Khan

Filters_save_Datagrid_Sample.oml

Hi Tousif, thanks so much for your reply and effort. I will look a little bit more into Goncalo's comments, but this is already a good option!

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.