Search code examples
jquerycssasp.net-mvcasp.net-ajaxjquery-jtable

Apply chosen to jtable multi select dropdown


I'm wondering how to apply chosen to multi-select drop-down in jtable. I've tried adding chosen-select as class but its not working. I've tried ajaxComplete also to check whether it might not be working because of ajax completion but it didn't help.

Here's my code:

 $(document).ajaxComplete(function () {
    $(".chosen-select").chosen();
 }); //post ajax

Also I've tried with data-rel="chosen" to in jquery.jtable.js, but it didn't help either. The multi-select list is coming but the problem is I have to show over 3500 locations in the list and it would become difficult to scroll and search locations, so that's why I want to use chosen so that I can search in the text box which it suggests and one can easily select, and delete locations. I've tried posting images but reputation prevented me from doing that.


Solution

  • Finally got the solution. Need to do slight modification in jquery.jtable.js

    Need to add two below lines before return statement inside _createDropDownListMultiForField function

    var $select_option = $('<script>  $(".chosen-select").chosen();  $(document).ajaxComplete(function () { $(".chosen-select").chosen();});</script> ');
    $containerDiv.append($select_option);
    return $containerDiv;