Adding custom column to the Samples table (view) issue

Hi,

We want to have Patient ID as a column in the Samples Table.

As it defined in Senaite.App.Lisitng manual:

  1. Created own subscriber:
    class PatientSamplesView(object):
        adapts(IListingView)
        implements(IListingViewAdapter)

        def __init__(self, listing, context):
            self.listing = listing
            self.context = context

        def before_render(self):
            self.listing.columns["PatientID"] = {
                "title": "Patient ID",
                "toggle": True,
                "sortable": True,
            }

        def folder_item(self, obj, item, index):        
            obj = api.get_object(obj)
            patient = get_obj_from_field(obj, 'Patient', None)
            patient_id = api.get_id(patient)
            patient_url = api.get_url(patient)
            item["PatientID"] = patient_id
            item["replace"]["PatientID"] = get_link(pa_url, value=patient_id)
            return item
  1. Registred adapter in configure.zcml

As the result:

  • adapter works;
  • AJAX-request delivers Patient ID values for each table item;
  • column name added to “Configure table columns” - section (where you can toggle and reorder columns);

BUT column not showing in the Samples table. No manipulations help (resetting/reorder columns).

Any idea where to look?

Plone ver: 5.2.4
Senaite.lims: 2.x (latest)
Senaite.core: 2.x (latest)

1 Like

Hi @toropok,

you need to add your column key to the review_states config for the states it should be displayed.
I think this part is missing in the howto…

Best regards,
Ramon

1 Like

Thank you @ramonski

that worked perfectly:

def before_render(self):
       
        ....
 
        review_states = [self.listing.review_states[0]]
        for review_state in review_states:
            review_state.update({"columns": self.listing.columns.keys()})    

regards,
–Leo

1 Like