title: How to adjust the column width of jqgrid AFTER the data is loaded?
body: <p>My ultimate goal is to have jqgrid to auto-set the column width according to the data content.  As part of the path to go there, I need to be able to set the column width AFTER the data is loaded by which time I would know the maximum width of each column.  But once I know the maximum width of a column, how can I set the width of each column in the "loadComplete" event and have the grid refresh with the new width of each column?  Most of the posts I've found on the net are regarding the grid's overall width.  What I want is to set each individual column's width and have the horizontal scrollbar appear automatically if the total width is too long.</p>
  
  <p><strong>Update</strong>: After seeing Oleg's awesome demo, I ended up coding this in the dqGrid (4.5.4) itself.  Here's what I did:</p>
  
  <p>Locate the function </p>
  
  <pre><code>addJSONData = function(data,t, rcnt, more, adjust) {
  </code></pre>
  
  <p>then locate within this function</p>
  
  <pre><code>            for (j=0;j&lt;rowReader.length;j++) {
                  v = $.jgrid.getAccessor(cur,rowReader[j]);
                  rd[ts.p.colModel[j+gi+si+ni].name] = v;
                  rowData.push(addCell(idr, v, j + gi + si + ni, i + rcnt, cur, rd));
  
                  // my addtion: stores the largest header size
                  var newWidth = v.length * 6; 
                  if (ts.grid.headers[j].width &lt; newWidth) {
                      ts.grid.headers[j].width = newWidth;
                  }
              }
  </code></pre>
  
  <p>Then right before the end } of this function, add the following</p>
  
  <pre><code>        // my addition: invoke the resizing logic
          for (j = 0; j &lt; rowReader.length; j++) {
              ts.grid.resizing = { idx: j };
              ts.grid.dragEnd();
          }
  </code></pre>
  
  <p>After that, the grid will adjust the width of each column according to the content.  One thing I still need help on is how to calculate preciously the new width.  My current hard-coded calculation</p>
  
  <p>var newWidth = v.length * 6; </p>
  
  <p>is obviously not very scalable.</p>