3

We are working on a website where we are using jqGrid to show the data. Now we have a requirement to change the grid header text alignment to left. We are using jqGrid in many places.

We already tried the below method to change the alignment and is working properly.

$("#tableName").jqGrid('setLabel', 'ColumnName', '', {'text-align':'left'});

But as I told this application is using jqGrid in many places. So to change the alignment we have to do updates in many places.

Since this change needs to be done in all places where we are using jqGrid, whether any common place is available to do this update, so that we can avoid updates in many places.

jqGrid Version - 4.5.4

Thanks in advance.

Mahesh KP
  • 6,248
  • 13
  • 50
  • 71
  • I am not sure . With reference to http://stackoverflow.com/questions/3003187/jquery-jqgrid-how-to-set-alignment-of-grid-header-cells. I think we need to define a class for it and then assign it to each grid. – Jayaraj.K Feb 05 '16 at 05:46
  • @Jayaraj.K : But this is exactly same as what we have done only they are using some class instead of inline style. But I want more of a common place to do the update which will change alignment of all grid header. – Mahesh KP Feb 05 '16 at 05:57

1 Answers1

1

Please write always, which version of jqGrid and from which fork (free jqGrid, Guriddo jqGrid JS or an old jqGrid in version <=4.7) you use.

I develop free jqGrid fork of jqGrid since more as one year and have published many versions of the fork. The current version is 4.12.1. Already in the first version of free jqGrid (see the readme 4.8) I included some simple extensions which you need: new property labelAlign which allows to align column headers. Possible values are "left", "right" and "likeData". No value means center alignments. The old demo demonstrates the usage of new labelAlign and labelClasses properties.

If you need

cmTemplate: { labelAlign: "left" }

You can set the value using $.jgrid.defaults:

$.extend(true, $.jgrid.defaults, {cmTemplate: { labelAlign: "left" }});

see https://jsfiddle.net/OlegKi/h3ksrjmp/

Oleg
  • 220,925
  • 34
  • 403
  • 798