working jqGrid Example

by suleman shahab

HTML

<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/themes/base/jquery-ui.css">
<link rel="stylesheet" href="http://trirand.com/blog/jqgrid/themes/ui.jqgrid.css">
<script src="http://trirand.com/blog/jqgrid/js/i18n/grid.locale-en.js"></script>
<script src="http://trirand.com/blog/jqgrid/js/jquery.jqGrid.min.js"></script>
<table>
  <tr>
    <td>
      <select>
        <option>1</option>
        <option>2</option>
      </select>
    </td>
  </tr>
  <tr>
    <td>
      <select>
        <option>3</option>
        <option>4</option>
      </select>
    </td>
  </tr>
</table>

<table id="grid"></table>

JavaScript

var data = [
  [48803, "AAF1", "", "02200220", "OPEN", "D,AB", "D,AC", "E,AD", "F,AE", "D,AD"],
  [48769, "AAD33", "", "77733337", "OPEN", "D,AB", "D,AB", "E,AD", "F,AD", "D,AB"]

];

var op1 = {
  value: '1:D; 2:E; 3:F'
};
var op2 = {
  value: '1:AB;2:AC; 3:AD; 4:AE'
};

var arr1 = ["D", "E", "F"];
var arr2 = ["AB", "AC", "AD", "AE"];


$("#grid").jqGrid({
  datatype: "local",
  height: 250,
  colNames: ['ID', 'CPR', 'Blank', 'DeptID', 'Status', '01', '02', '03', '04', '05'],
  colModel: [{
    name: 'ID',
    index: 'ID',
    width: 50,
    sorttype: "int"
  }, {
    name: 'CPR',
    index: 'CPR',
    editable: true,
    width: 60,
    sorttype: "date"
  }, {
    name: 'blank',
    editable: true,
    index: 'blank',
    width: 10
  }, {
    name: 'DeptID',
    index: 'DeptID',
    editable: true,
    width: 60,
    sorttype: "float"
  }, {
    name: 'Status',
    index: 'Status',
    width: 60,
    sorttype: "float"
  }, {
    name: '01',
    index: '01',
    editable: true,
    edittype: "select",
    formatter: myformatter,
    editoptions: op2,
    width: 30,
  }, {
    name: '02',
    index: '02',
    editable: true,
    edittype: "select",
    formatter: myformatter,
    editoptions: op1,
    width: 30,
  }, {
    name: '03',
    index: '03',
    editable: true,
    edittype: "select",
    formatter: myformatter,
    editoptions: op1,
    width: 30,
  }, {
    name: '04',
    index: '04',
    editable: true,
    edittype: "select",
    formatter: myformatter,
    editoptions: op1,
    width: 30,
  }, {
    name: '05',
    index: '05',
    editable: true,
    edittype: "select",
    formatter: myformatter,
    editoptions: op1,
    width: 30,
  }, ],
  'cellEdit': true,
  caption: "Stack Overflow Example",
  // ondblClickRow: function(rowid,iRow,iCol,e){alert('double clicked');}
});

var names = ['ID', 'CPR', 'Blank', 'DeptID', 'Status', '01', '02', '03', '04', '05'];
var mydata = [];

for (var i = 0; i < data.length; i++) {
  mydata[i] = {};
  for (var j...