[ckan-dev] ckanext-scheming multiple_selected display issue (displays as an array)

Biz Tweets optweets at gmail.com
Thu Sep 6 05:41:45 UTC 2018


Please see (https://github.com/ckan/ckanext-scheming/issues/139) for more
information

If you set a field group in dataset.json to a multiple selected present
such as

"preset": "multiple_select" or "preset": "multiple_checkbox"

It seems to save the selected options into an array and will display in an
array on the facet list on the left hand side as so below:

I followed what vithalalapati said and made a custom plugin with the
following below:

The facets_dict that im trying to print which has multiple selected fields
is customer_area. Yet its still printing the facets_list in an array as so
"["consumerdiscretionary", "consumerstaples"]"

Because of this when you click it, it searches for the entire array rather
than individually such as consumerdiscretionary or consumerstaples.

Does anyone know or have a suggestion of how to save multiple selected
fields in a non array fashion or display them in a non array fashion?


class FacetViewPlugin(plugins.SingletonPlugin):
    plugins.implements(plugins.IConfigurer)
    plugins.implements(plugins.IFacets, inherit=True)
    plugins.implements(plugins.ITemplateHelpers)

    def update_config(self, config_):
        toolkit.add_template_directory(config_, 'templates')
        toolkit.add_public_directory(config_, 'public')
        toolkit.add_resource('fanstatic', 'facetview')

    # IFacets
    def dataset_facets(self, facets_dict, package_type):
        # We will actually remove all the core facets and add our own
        facets_dict.clear()
        facets_dict['file_type'] = plugins.toolkit._('File Type')
        facets_dict['allowed'] = plugins.toolkit._('Allowed?')
        facets_dict['organization'] = plugins.toolkit._('Organization')
        facets_dict['cert'] = plugins.toolkit._('Cert')
        #This one prints as an array below:
        facets_dict['customer_area'] = plugins.toolkit._('Customer Area')
        facets_dict['tags'] = plugins.toolkit._('Tags')
        return facets_dict


Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20180906/d72087f6/attachment.html>


More information about the ckan-dev mailing list