Manage display: Format- Table. Add Align settings to collumns.

Created on 6 July 2023, over 1 year ago
Updated 30 August 2023, over 1 year ago

Problem/Motivation

Tables fields have numbers, strings and other types data. Will be nice have settings for Align on Manage Display for format table.
Same as for Views columns: Left, Center, Right.

Thank you for module.

Feature request
Status

Closed: works as designed

Version

1.0

Component

Code

Created by

🇨🇦Canada psaleks

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @psaleks
  • Status changed to Closed: works as designed over 1 year ago
  • 🇫🇷France lazzyvn paris

    no It will never add this option. It can be fixed easier with custom theme or custom js.
    Try with bootstrap 5 admin theme it has auto col table

  • 🇨🇦Canada psaleks

    I want to reopen this issue, because I do not like to use table with numbers (that usually align to right) without align and create extra module for this. Align settings should be in module without extra coding for each site.

    I looked in the code version 1.0.19 and change a little only for mode Table. Please can you review changes and if possible to add to module.

    1. css/tablealign.css
    2. datafield.libraries.yml Add to end
    datafield_table_align:
    css:
    component:
    css/tablealign.css: { }

    3. src/Plugin/Field/FieldFormatter/DataFieldTable.php Inside file I entered changes between lines //my .....//endmy( 7 changes). Example below

      foreach ($subfields as $subfield) {
          $item = $field_settings['columns'][$subfield];
          $title = $field_settings["field_settings"][$subfield]["label"] ?? $item['name'];
          $element['formatter_settings'][$subfield]['column_label'] = [
            '#type' => 'textfield',
            '#title' => $this->t('Column label: %title', ['%title' => $title]),. 
            '#attributes' => ['placeholder' => $this->t('Column label')],
            '#default_value' => $setting[$subfield]['column_label'] ?? $title,
          ];
    //my
          $element['formatter_settings'][$subfield]['align'] = [
            '#type' => 'select',
            '#title' => $this->t('Align'),               
            '#default_value' =>!empty($setting[$subfield]['align']) ? $setting[$subfield]['align']: '',
    				'#options' => [
              '' => $this->t('None'),
              'data-field-align-left' => $this->t('Left'),
              'data-field-align-center' => $this->t('Center'),
              'data-field-align-right' => $this->t('Right'),
            ],
          ];				
    //endmy		
    

    I attached files. Last two i added extension txt for uploading

  • Status changed to Active over 1 year ago
  • Status changed to Closed: works as designed over 1 year ago
  • 🇫🇷France lazzyvn paris

    Thanks you for your contribution but I must reject your work,
    - the code does not respect drupal standards
    - use data-xxx for style?
    - too much configuration for this version, I think just add algin=right or dir=rtl for numeric type, it is easier to fix your problem
    - no need 'cos user can change with css or override data field format

    btw: i add rtl for number you can try in new version

Production build 0.71.5 2024