title: Jquery datatables: How to search only selected options inside html select field
body: <p>I have a html <code>multi select field</code> in one column of jquery datatable(<a href="http://datatables.net" rel="nofollow">http://datatables.net</a>), I want to search(from its default search box) only selected options in select fields and not unselected ones . Its currently searching all the text inside select field.</p>
  
  <p>What I would need is to remove unselected options from search. </p>
  
  <p>Can anyone suggest how to do it ?<br>
  Thanks. </p>
  
  <p><strong>Edit:</strong> I have created custom <code>sType</code> and defined <code>$.fn.dataTableExt.ofnSearch</code> for it. As specified at- (<a href="http://datatables.net/development/filtering" rel="nofollow">http://datatables.net/development/filtering</a>) in "Type based column filtering". Code is Given below:- </p>
  
  <pre><code>$.fn.dataTableExt.aTypes.push(
      function ( sData )
      {
          var ishtml=sData.match(/&lt;select(?:.)*?&gt;.*&lt;\/select&gt;/gm);
  
  
          if (ishtml)
          {
              return 'comments';
          }
          return null;
      }
  );
  
  $.fn.dataTableExt.ofnSearch['comments'] = function ( sData ) {
     return sData.replace(/&lt;select(?:.)*?&gt;.*&lt;\/select&gt;/gm, "");
  }
  </code></pre>
  
  <p>And added <code>stype</code> to columndef in .dataTable( { } ) </p>
  
  <pre><code>"aoColumnDefs": [{ "sType": "comments", "aTargets": [ 8 ] }],
  </code></pre>
  
  <p>It will remove complete select element text (selected and unselected both)from search. Then I will use jquery to add selected options to hidden div outside of select to let them available in search.
  But this is still considering select field text in search.</p>
  
  <p>Any ideas? Please let me know if any one can help.   </p>