List (from data source) - Conditionally hide fields in details popup

Hi,

I have a form that takes the user down one of two lines of questioning depending upon the answer selected in a dropdown list. In the form I can hide the fields that are not relevant.

I use the data source from the form to populate a list (from data source) widget. When the user clicks on one of the list items it brings up the details view popup but, as expected, it shows every single field that was available on the form, including the questions that the user did not answer.

Is it possible to conditionally hide fields in the details view popup? I have tried:

Fliplet.Hooks.on(‘flListDataAfterRenderList’, function(options){
options.config.beforeShowDetails = function(opt) {
var data = opt[‘data’][‘originalData’];
var fieldUsedtoHideOrShowThings = data[‘SomeField’];

// but what now ??? …
};
});

but these events do not give me any way of manipulating what gets rendered as I only have access to the template html.

Am I on the right track? Is this possible?

Thanks
Andy

Hi Andy,

Yes this is possible. If you want to manipulate what data is shown in the detail view overlay for a List from data source widget you need to use this hook and setting. Inside this hook which fires when an entry is clicked you can see the entry that will be rendered and you can manipulate it here.

Fliplet.Hooks.on('flListDataBeforeGetData', function(options) {
  options.config.beforeOpen = function(data) {
    //e.g. delete the Location column from rendering
    delete data.entry.data.Location
  };
});

See docs: List (from data source) | Fliplet Developers Documentation

Hope this helps,
Deb

Perfect thanks