How to search only selected options inside html select field

How to search only selected options inside html select field

pankajshrpankajshr Posts: 3Questions: 0Answers: 0
edited January 2013 in General
Hi ,
I have a html multi select field in one column of table, I want to search only selected options in select fields and not unselected ones . Its currently searching all the text inside select field.

Can anyone suggest how to do it ?

Replies

  • pankajshrpankajshr Posts: 3Questions: 0Answers: 0
    edited January 2013
    Okay. I have created custom sType and defined $.fn.dataTableExt.ofnSearch for it. As specified at- (http://datatables.net/development/filtering) in "Type based column filtering". Code is Given below:-
    [code]
    $.fn.dataTableExt.aTypes.push(
    function ( sData )
    {
    var ishtml=sData.match(/.*<\/select>/gm);


    if (ishtml)
    {
    return 'comments';
    }
    return null;
    }
    );

    $.fn.dataTableExt.ofnSearch['comments'] = function ( sData ) {
    return sData.replace(/.*<\/select>/gm, "");
    }
    [/code]

    And added stype to columndef in .dataTable( { } )
    [code]
    "aoColumnDefs": [{ "sType": "comments", "aTargets": [ 8 ] }],
    [/code]

    It will remove text inside select from search. Then I will use jquery to add selected options to hidden div outside of select field to let them available in search.
    But this is still considering select field text in search.

    Any ideas? Please let me know if any one can help.
This discussion has been closed.