Hello Team
In Angular multiselct checkbox module, I am trying to have an option where user can choose then
its input box is enabled and user can type his response.
Following is what we are trying to work on,
but when we click on input box in the template - we cannot enter any value into it as the focus shifts to multiselect filter box.
https://stackblitz.com/edit/angular-8q2osa?file=app.component.html
Hope we can make it working and use this awesome multiselect tool in checkbox mode.
|
<div id="multiselect-sample" class="control-section">
<div class="control-styles">
<h4>Custom Values</h4>
<ejs-multiselect id="custom-list" #custom [dataSource]="gameList" [allowCustomValue]="true" [mode]="box"
(filtering)="onFiltering($event)" [placeholder]="waterMark" [fields]="fields">
<ng-template #noRecordsTemplate>
<div id="nodata">
No matched item, do you want to add it as new item in list?
</div>
<button (click)="addNewItem($event)" class="e-control e-btn">
Add New Item
</button>
</ng-template>
</ejs-multiselect>
</div>
</div>
|
|
public addNewItem = () => {
// get the typed characters
let customValue: string = ((this
.multiObj as any).filterParent.getElementsByClassName(
'e-input'
)[0] as HTMLInputElement).value;
// make new object based on typed characters
let newItem: { [key: string]: Object } = {
Game: customValue,
Id: customValue
};
// new object added to data source.
(this.multiObj.dataSource as Object[]).push(newItem);
// pass new object to addItem method.
this.multiObj.addItem(newItem);
(this.multiObj as any).listData.push(newItem);
};
|
Thank you Deepak
we do not want new item to push to the list for various business reasons.
we want user to enter his value if its not one of the above listed
we are able to achieve this with template - i think only issue is its not allowing us to focus on it, can you please check and see how we can get focus on it.
Mohit.
|
public OnOpen(args) {
args.popup.element.addEventListener('mousedown', (e) => {
if (e.target.parentElement.parentElement.id == 'footerElement') {
e.target.focus();
}
});
} |
Hello Berly
Thank you for your response
Looks like on Mac Chrome its still showing same behavior and not working
Please see attached zip screen recording.
Ok Thank you Berly,
Hi Berly
Thank you -
Is it possible to highlight what changes need to be applied. We attempted to implement at our end but are not successful.
Also with this implementation, do we loose the two way binding of input field on template? or is ti possible to maintain the binding as the value of input will be very important to us.
Thank you
Mohit
|
args.popup.element.addEventListener('mousedown', (e) => {
if (e.target.id == 'footerElement') {
e.target.focus();
e.target.addEventListener('input', (e) => {
console.log((event as any).data);
});
}
}); |