I am creating dynamic select in script.
$.each(data, function (i) {
optionhtml = '<option value="'
data[i].CustomerId + '">' + data[i].CustomerId + ' _ ' + data[i].PurchaseDate + ' _ ' + data[i].SupplyDate + ' _ ' + data[i].SupplierName + '</option>';
$("select[id='ddlAdm" + arrElem[0]']").append(optionhtml);
});
This works well. Select displays text in dropdown for CustomerId+PurchaseDate+SupplyDate+SupplierName
However I want to add header in select for this.
CustomerId PurchaseDate SupplyDate SupplierName
123 10/11/2016 10/15/2018 XYZ
123 10/16/2018 10/23/2018 PQR
I really want to skip autoplete and typeahead plugin for this. Need to add header in select.
I am creating dynamic select in script.
$.each(data, function (i) {
optionhtml = '<option value="'
data[i].CustomerId + '">' + data[i].CustomerId + ' _ ' + data[i].PurchaseDate + ' _ ' + data[i].SupplyDate + ' _ ' + data[i].SupplierName + '</option>';
$("select[id='ddlAdm" + arrElem[0]']").append(optionhtml);
});
This works well. Select displays text in dropdown for CustomerId+PurchaseDate+SupplyDate+SupplierName
However I want to add header in select for this.
CustomerId PurchaseDate SupplyDate SupplierName
123 10/11/2016 10/15/2018 XYZ
123 10/16/2018 10/23/2018 PQR
I really want to skip autoplete and typeahead plugin for this. Need to add header in select.
Share Improve this question asked Jan 19, 2017 at 5:45 Johny BravoJohny Bravo 4241 gold badge10 silver badges35 bronze badges1 Answer
Reset to default 6You can add header to select element using optgroup
You can check demo jsfiddle/bharatsing/bgd9bobo/
<select>
<optgroup label = "CustomerId PurchaseDate SupplyDate SupplierName">
<option value ="123 10/11/2016 10/15/2018 XYZ">123 10/11/2016 10/15/2018 XYZ</option>
<option value ="123 10/16/2018 10/23/2018 PQR">123 10/16/2018 10/23/2018 PQR</option>
</optgroup>
</select>
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744323064a4568515.html
评论列表(0条)