Hi,

I created a view with sorting but in my case all the headings in the first row slip one column to the right, see screenshot: each heading in the first row needs to be placed one step to the left. When I disable the lable creation for the weight field in the views settings the heading in the column is simply empty. Looking at the markup it is really that way: in the heading row there are 6 cells - the first cell for the weight field label, the second cell for the title label and so on. In the table body the first cell is (as it should be) the title field with included weight selector, the second cell for the type and so.

Best,
Tobias

Comments

tobiberlin created an issue. See original summary.

ziomizar’s picture

This is related to #2689377: Tabledrag handles are hidden the weight selector has been moved automatically to the first column but the table heading still in the original position

tobiberlin’s picture

I tried to unset the header column but then I got a JavaScript error.

In weight_preprocess_views_view_table() line 26 I tried to remove the heading column of the weight field but then I get a JavaScript error:

      // Add the tabledrag attributes.
      foreach ($variables['rows'] as $key => $row) {
        if ($is_first_column) {
          // If the weight selector is the first column move it to the last
          // column, in order to make the draggable widget appear.
          $weight_selector = $variables['rows'][$key]['columns'][$field->field];
          unset($variables['rows'][$key]['columns'][$field->field]);

          unset($variables['header'][$field->field]);

          $variables['rows'][$key]['columns'][$field->field] = $weight_selector;
        }
        // Add draggable attribute.
        $variables['rows'][$key]['attributes']->addClass('draggable');
      }

The JavaScript error says: Uncaught TypeError: Cannot read property 'colSpan' of undefined.

ziomizar’s picture

Hi tobiberlin,

You should not just unset the header. You should move the header column to the same position of the selector, so to the last position.

          $weight_selector = $variables['rows'][$key]['columns'][$field->field];
          unset($variables['rows'][$key]['columns'][$field->field]);
          $variables['rows'][$key]['columns'][$field->field] = $weight_selector;

This code unset just because when is recreated it goes to the last column. You should do something like:

          $weight_selector = $variables['rows'][$key]['columns'][$field->field];
          unset($variables['rows'][$key]['columns'][$field->field]);
          $variables['rows'][$key]['columns'][$field->field] = $weight_selector;

          $header_weight_selector = $variables['header'][$field->field];
          unset($variables['header'][$field->field]);
          $variables['header'][$field->field] = $header_weight_selector;

In that way both should be in the same position

tobiberlin’s picture

StatusFileSize
new748 bytes

Thank ziomizar, this exactly solved the problem. Find attached a patch

ziomizar’s picture

Status: Active » Needs review
ziomizar’s picture

StatusFileSize
new750 bytes

Tobiberlin thanks for the patch!

I've fixed some indentation issues there like tabs instead of spaces and to many spaces per row.

  • tobiberlin authored c00b053 on 8.x-3.x
    Issue #3092490 by tobiberlin, ziomizar: Table heading row slips one...
ziomizar’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.