Filter in a table

Dear all,

I’ve a table with a column “DATE” and I’d like to know if and how it is possible to add a filter a the top of the column in order to class documents by the oldest one for example.
Do you have an idea?

Thanks for your help

Dear Yan,

It is possible and you need to click on settings of the format. Then, you can select which field will be sortable.

Best regards,
Kamila

Dear Kamila,

Thanks for your answer however I don’t find where you clicked to have access to this windows. Sorry I’m a beginner in Drupal 8 could you please show me the steps?

Thanks
Yan

Dear Yan,

You have to go to a view. When you are there you should see a format and choose “Settings” right next to “Table”.

Kamila

Dear Kamila,

Sorry I don’t find this “Settings”. You are in “edit mode” or “view mode”? Maybe I have to download a module?

Thanks

Yan

Hello Yan,

There are two kinds of tables on Drupal.

  1. Custom tables that you add using the CK Editor in a text field.
  2. Create a view table that shows dynamic content using a view.

Kamila refers to the second case. In that case you can select some fields of the content you are showing to be sortable in the way Kamila showed. In that case an SQL query is executed to sort the results. That can happen because the content is dynamic.

I guess that you refer to the case, so you added a table in the Editor. Either you use the widget to generate the table or you do it in a custom way, in both cases an HTML table is generated. HTML tables are not sortable by default. In order to make it sortable you need to write some Javascript.

To conclude, if you are using a view then use the way Kamila showed. If you are adding an HTML table, then there is no way to do it without adding some javascript or writing a module.

Since you are a beginner, I would advise you to have a look on the Beginners’ guide of Drupal.

Let me know if you have more questions

Konstantinos