title: jqGrid custom input element needs handle to parent table
body: <p>I'm using jqGrid to build a custom inline entry widget on a page. The relevant part of the jqjGrid setup is:</p>
  
  <pre><code>  colModel:[  {
           // Other columns removed.
      {name:'ship',index:'ship', width:90, editable: true, sortable: false, 
              edittype: "custom",
              editoptions:{ custom_element: customElement, 
                              custom_value: customValue} }
      ], 
  </code></pre>
  
  <p>And my callback function is:</p>
  
  <pre><code>function customElement(value, options) {
      var a = $("&lt;input&gt;").attr({ 
                  type: 'text', 
                  size: 2,
                  value: value,
                  style: 'float: left'
          }).add(
              $("&lt;span&gt;").attr({ 
                  style: 'float: left; margin-top: 2px;',
                  'class': 'ui-icon ui-icon-search'
          }).click(function() {
                      // My custom function here.
             })
          ).appendTo($("&lt;div&gt;"));
  
      return a;
  }
  </code></pre>
  
  <p>This all works properly.</p>
  
  <p>However, I'm building a library to manage several jqgrid tables on a page.  I'd like to use the same function to build the custom elements on several of those tables.  The problem is that this particular <code>click()</code> function needs to know which jquery table it's dealing with.</p>
  
  <p>I can get the table ID through a hacky way at the beginning of <code>customElement</code> and pass it in the closure to the function:</p>
  
  <pre><code>var fieldID = options.id;
  var rowID = fieldID.replace(/_.*/, "");
  var containingTable = $("#" + rowID + "_id").closest("table");
  </code></pre>
  
  <p>But this assumes that the column "id" exists in the current jqGrid, and it's an earlier (leftward) column.  I can't use the "ship" column because it hasn't been created yet.  I can't assume there are other rows in the table that would have a "ship" column either.</p>
  
  <p>How can I, in a custom_element handler, reliably get a handle to the "calling" table?</p>