再会我下面的代码将仓库列表填充到下拉列表中,这是我想要的,但我也希望isMainWarehouse = true在填充仓库时使用默认选择的仓库(请注意,只有一个主仓库)function PopulateWarehouses() {var warehouseDropDown = document.getElementById('SelectWarehouse');var warehouseFragment = document.createDocumentFragment();_warehouseRepository.getWarehouses().done(function (data) { for (var element in data.items) { if (data.items.hasOwnProperty(element)) { var recievedData = data.items[element]; var id = recievedData.id; var name = recievedData.warehouseName; var main = recievedData.isMainWarehouse; var opt = document.createElement('option'); opt.innerHTML = name; opt.value = id; warehouseFragment.appendChild(opt); } } warehouseDropDown.appendChild(warehouseFragment); $('#SelectWarehouse').selectpicker('refresh');});}这是我的下拉菜单 <select id="SelectWarehouse" name="SelectWarehouse" class="selectpicker show-tick form-control" data-live-search="true"></select>这个方法只是获取所有仓库的列表 // GET: get list of all warehouses public async Task<ListResultOutput<WarehouseListDto>> GetWarehouses() { var warehouses = await _warehouseRepository.GetAllListAsync(); ListResultOutput<WarehouseListDto> dto = new ListResultOutput<WarehouseListDto>( warehouses .OrderBy(t => t.WarehouseName) .ToList() .MapTo<List<WarehouseListDto>>() ); return dto; }
1 回答
- 1 回答
- 0 关注
- 159 浏览
添加回答
举报
0/150
提交
取消