Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 13th, 2012  |  syntax: None  |  size: 1.71 KB  |  hits: 49  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. jqGrid: format cell value without changing actual (underlying) value?
  2. { name: 'Id', index: 'Id', editable: true, hidden: true,  
  3.      editoptions: { defaultValue: row_id,
  4.                     dataUrl: "DataService.asmx/GetList",
  5.                     buildSelect: function (data) {
  6.                                  var s = '<select>';
  7.                                  if (data && data.d) {
  8.                                     //data is nested, so we need a few steps to get to the actual data
  9.                                     var list = data.d;
  10.                                     var opts = JSON.parse(list);
  11.                                     var subList = opts.List;
  12.                                     //loop through the data to build the options list
  13.                                     for (var i = 0, l = subList.length; i < l; i++)
  14.                                         {   var ri = subList[i];
  15.                                             s += '<option value=' + ri.Id + '>' + ri.Name + '</option>';
  16.                                         }
  17.                                   }
  18.                                   else {
  19.                                      s+= "<option value=0>No data to display</option>";
  20.                                   }
  21.                                   return s + "</select>";
  22.                             } ,
  23.                       dataEvents: [
  24.                               { type: 'change',
  25.                                 fn: function (e) {
  26.                                         $('input#Id').val(this.value);
  27.                                 }
  28.                               }
  29.                               ]
  30.  
  31.                      },
  32.        editrules:  {edithidden: true},
  33.        edittype: 'select'