title: jqGrid TreeGrid not send additional data to server
body: <p>I have a jqGrid Treegrid defined as below:</p>
  
  <pre><code>$('#MyGrid').jqGrid({
      colNames: ['Id','Nome','Nivel','Combo',''],
      colModel: [
          { hidden: true, name: 'Id' },
          { editable: true, name: 'Nome' },
          { hidden: true, name: 'Nivel' },
          { name: 'Combo', editable: true, edittype: 'select',
              editoptions: {
                  buildSelect: createSelectList ,
                  dataUrl: '/Home/GetCombo' // &lt;-- to this controller, I want
                      // to send the id of the row edited to load custom items
                      // in select object
              }}, 
          { formatter: 'actions', formatoptions: { keys: true },
              resizable: false, search: false, sortable: false,
              width: 60, viewable: false, name: 'actions' }
      ],
      cellEdit: true,
      url: '...',
      datatype: 'json',
      editurl: '...',
      jsonReader: {
          repeatitems: false,
          id: 'Id',
          subgrid: { repeatitems: false }
      }, 
      mtype: 'POST',
      gridComplete: function() { myOnGridComplete(); },
      ajaxSelectOptions: {
          data: {
              tempid: function () {
                  // !!! the next line always returns null
                  return $('#MyGrid').jqGrid('getGridParam', 'selrow');
              }
          }
      }, 
      prmNames: { npage: 'npage' }, 
      rowNum: -1,
      ExpandColClick: true,
      ExpandColumn: 'Nome',
      treeGrid: true,
      treeGridModel: 'adjacency',
      width: 700,
      height: '100%'
  });
  </code></pre>
  
  <p>My goal is to send the current row ID to the server, but when I use <em>$('#MyGrid').jqGrid('getGridParam', 'selrow')</em> I always get a null value.</p>
  
  <p>I already read this posts but none of them solve my problem:</p>
  
  <ul>
  <li><p><a href="https://stackoverflow.com/questions/8148843/having-trouble-with-jqgrid-dataurl-function-code-segment/8150307#8150307">having trouble with jqgrid dataUrl function code segment</a></p></li>
  <li><p><a href="https://stackoverflow.com/questions/8063876/jqgrid-setselect-function-with-parametrized-query/8067258#8067258">jqGrid setSelect function with parametrized query</a></p></li>
  <li><p><a href="https://stackoverflow.com/questions/841739/jqgrid-how-to-populate-select-list-from-query">jqGrid, how to populate select list from query</a></p></li>
  </ul>
  
  <p>Any sugestions?</p>
  
  <p>tks in advance!</p>
  
  <p><strong>Update 1:</strong></p>
  
  <p>The TreeGrid bind is ok. The real problem is when I click the Edit Button in the leaf node. In this event, I want to send additional data to the server. </p>
  
  <p>I tried to accomplish this using the <code>ajaxSelectOptions</code>, but this command always returns null: <code>$('#MyGrid').jqGrid('getGridParam', 'selrow')</code></p>
  
  <p><strong>Workaround</strong></p>
  
  <p>This is a workaround that I did before Oleg's help:</p>
  
  <p>Step 1: Create a hidden field in the HTML</p>
  
  <p>Step 2: In my myOnGridComplete function, I set a click event to the edit button:</p>
  
  <pre><code>function onGridAjusteDTOComplete()
  {
      $('#MyGrid').find('span.ui-icon-pencil').each(function() {
          $(this).click(function(){
              var rowID = $(this).parents('tr').attr('id');
              // !!! the next commented line not work in my case
              // $('#MyGrid').jqGrid('setSelection', therowid );
              $('#myHiddenField').val(rowID); // &lt;-- this works
          });
      });
  }
  </code></pre>
  
  <p>Step 3: Get the <code>rowID</code> from the hidden field in the <code>ajaxSelectOptions</code>:</p>
  
  <pre><code>ajaxSelectOptions: "{type: 'GET', contentType: 'application/json; charset=utf-8',dataType: 'json',cache: false, async:false, data: {id: function () { return $('#myHiddenField').val(); }}}"
  </code></pre>
  
  <p><strong>Solution</strong></p>
  
  <p>See the solution provided by Oleg below. It's just amazing. Thank you Oleg.</p>