I am using jquery multi-select drop down in my project. I have a drop down with maximum 4 value and if I select a value from the drop-down it is displaying as '3 selected', '4 selected' as bellow image, but I want to display all selected value as coma separate instead of '4 selected'. I am using /bootstrap-multiselect.js
I am generating dropdown dynamically as bellow html code,
@if (ds.Tables.Count > 0)
{
int i = 1;
foreach (DataRow categogyItem in ds.Tables[0].Rows)
{
<div class="ibvm subhselectfildwrap">
<select class="listbox selectpicker" id=@string.Format("ddlEmail{0}", i) multiple="multiple" name="@string.Format("Email{0}", i)" style="width: 500px !important;">
@if (ds.Tables.Count > 2)
{
foreach (DataRow EmailItem in ds.Tables[2].Rows)
{
if (NC.ToInt(EmailItem["IN00_01_InBoxId"]) == NC.ToInt(categogyItem["InBoxId"]))
{
<option value="@EmailItem["IN00_01_DetailID"]">@EmailItem["IN00_01_EmailId"]</option>
}
}
}
</select>
</div>
i++;
}
}
in the js file, I have created code as bellow, when I check this code while putting Debugger
in js it's working properly and button text has been changed with selected coma separator value but after then js has been called and value has been changed as '4 selected'.
I have referred sample question also. but I can not able to find the solution.
$('.selectpicker').multiselect({
enableFiltering: false,
includeSelectAllOption: true,
selectAllJustVisible: false,
enableCaseInsensitiveFiltering: true,
buttonWidth: '100%'
});
$("select").change(function () {
var str = "";
$("select option:selected").each(function () {
str += $(this).text() + ", ";
});
$(this).parent('.subhselectfildwrap').find('div.btn-group').find('span.multiselect-selected-text').text(str);
})
.trigger("change");
Edit:
I am using 'http://cdn.rawgit.com/davidstutz/bootstrap-multiselect/master/dist/js/bootstrap-multiselect.js'