title: flexigrid - how to change colmodel
body: <p>I'm using flexigrid to display some data from server via ajax. The thing is that I can't tell beforehand which columns are going to be displayed.</p>
  
  <p>How can I set the colModel based on the data retrieved?</p>
  
  <p>In the ajax file I added a "cols" key to the json that enumerates the columns that are found in the row.cell key:</p>
  
  <pre><code>{
      "page": "1",
      "total": 1,
      "rows": [
          {
              "id": "1",
              "cell": {
                  "id": "1",
                  "name": "Some data"
              }
          }
      ],
      "cols": [
          "id",
          "name"
      ]
  }
  </code></pre>
  
  <p>And in populate() I do this:</p>
  
  <pre><code>//ajax success
  p.colModel = {};
  var colModelItem = new Array();
  for(var col in data.cols)
  {
          colModelItem.push({
                  "display": data.cols[col],
                  "name": data.cols[col],
                  "width": 80,
                  "sortable": true,
                  "align": "center"
                  });
  }
  p.colModel = colModelItem;
  
  //g.addData(data);
  </code></pre>
  
  <p>After that I tried to use the functionality that creates the headers but with no success.</p>
  
  <p>Any ideas? thanks in advance!</p>