Remove "Show row weights" link

Public

Remove "Show row weights link" in the right way

</> CopyGet raw version
php
  1. function module_name_form_alter(&$form, &$form_state, $form_id) {
  2. // you can create "if logic" to grab a specific form
  3. $form['#attached']['js'] = array(
  4. drupal_get_path('module', 'module_name') . '/disable_show_row_weights.js',
  5. );
  6. }

Content of the disable_show_row_weights.js file

</> CopyGet raw version
javascript
  1. (function ($) {
  2. // based on http://drupal.stackexchange.com/questions/62662/
  3. // Copy hideColumns() method
  4. var hideColumns = Drupal.tableDrag.prototype.hideColumns;
  5. Drupal.tableDrag.prototype.hideColumns = function() {
  6. // Call the original hideColumns() method
  7. hideColumns.call(this);
  8. // Remove the 'Show row weights' string
  9. $('.tabledrag-toggle-weight').text('');
  10. }
  11.  
  12. // Copy showColumns() method
  13. var showColumns = Drupal.tableDrag.prototype.showColumns;
  14. Drupal.tableDrag.prototype.showColumns = function () {
  15. // Call the original showColumns() method
  16. showColumns.call(this);
  17. // Remove the 'Hide row weights' string
  18. $('.tabledrag-toggle-weight').text('');
  19. }
  20. })(jQuery);

Comments

SWAPNIL PHADKE's picture

Actually i try but not get success. show row weight not removed

netlooker's picture

Maybe a cache issue. Could you please, send more details.

dune's picture

So nice and easy!
Thank you

Essam Al-Qaie's picture

Hello,

I'd like to thank you for this snippet .. really helpful!

Why not put it in a small module instead of implement it every time I have a site asking for this to be removed! .. is there a one already? if not I can make this if that's alright with you

Thank you once again