abp
abp copied to clipboard
When using select2 there should be ability to specify an empty item
When using Select2 dropdown in MVC there should be an option to specify an empty Option
function initSelectUsers() {
$selectUser.data('autocompleteApiUrl', '/api/app/issue-tracking-user/assignable-users');
$selectUser.data('autocompleteDisplayProperty', 'name');
$selectUser.data('autocompleteValueProperty', 'id');
$selectUser.data('autocompleteItemsProperty', 'items');
$selectUser.data('autocompleteFilterParamName', 'filter');
abp.dom.initializers.initializeAutocompleteSelects($selectUser);
}
I suggest having
$selectUser.data('autocompleteEmptyDisplayProperty', 'Select User');
$selectUser.data('autocompleteEmptyValueProperty', '00000000-0000-0000-0000-000000000000');
using the below code in ProcessResults:
var mappedItems = _.map(data.items, function (item) {
return { id: item.id, text: item.userName };
});
mappedItems.unshift({ id: '00000000-0000-0000-0000-000000000000', text: 'Select User' });
return { results: mappedItems };
Related to https://github.com/abpframework/abp/issues/12130
Hi @vnetonline
Can you try to use data-allow-clear="true"
attribute for your select. That option will work if you inititialize it according to Auto-Complete Select Documentation
This is an example:
<select asp-for="Widget"
class="auto-complete-select"
data-allow-clear="true"
data-autocomplete-api-url="/api/example/authors"
data-autocomplete-display-property="name"
data-autocomplete-value-property="code"
data-autocomplete-items-property="items"
data-autocomplete-filter-param-name="filter">
</select>
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.