I want to be able to default this combobox with a value of 1, but have Proceed display in the form.
<ejs-combobox id='action' [dataSource]='actionData' formControlName="action"
[placeholder]="actionText" [fields]='actionFields' [autofill]='true'
></ejs-combobox>
public actionFields : Object = { text: 'action', value: 'id' };
public actionText : string = "Action to take";
public actionData: { [key: string]: Object }[] = [ { id: '1', Game: 'Proceed' },
{ id: '2', Game: 'Triage' }, { id: '3', Game: 'Reject - Forward' },{ id: '4', Game: 'Reject - Bounce Back' }];
I can’t seem to get it to display the text but store the value.
Further,
Is there a property to warn the user for a “Not in List” or validate the entry? I can’t find one.
In the above example, a user could type “Fred” and move on. It appears as a valid entry but clearly is not and the user would have no idea.
Thanks in advance
|
public actionFields: Object = { text: 'Game', value: 'id' };
public actionText: string = 'Action to take';
public actionData: { [key: string]: Object }[] = [
{ id: '1', Game: 'Proceed' },
{ id: '2', Game: 'Triage' },
{ id: '3', Game: 'Reject - Forward' },
{ id: '4', Game: 'Reject - Bounce Back' }
]; |
Thank you for your replies. It's moving foward.
Query1:
I have everything matching and the list displays.
public actionFields : Object = { text: 'action', value: 'id' };
public actionData: { [key: string]: Object }[] = [ { id: '1', action: 'Proceed' },
{ id: '2', action: 'Triage' }, { id: '3', action: 'Reject - Forward' },{ id: '4', action: 'Reject - Bounce Back' }];
What I want to be able to do is assign the value based on id.
If I pass in "2", the combobox shows me 2, not "Triage".
Query 2:
Even in your example, yes it shows you the warning message, but you can still leave the control and the value persists. If you type in "Nonsense" and leave, it still shows "Nonsense". Yes it may not be bound to anything but it appears that the value has been accepted.
Is there a property that forces an acceptable value, not permitting you to leave until it has one?
Thanks
|
createForm(): void {
this.skillForm = this.fb.group({
action: ['2', Validators.required]
});
} |
|
<ejs-combobox formControlName="action" name="action" [allowCustom]=false [dataSource]='actionData'
[placeholder]='autoreactiveplaceholder' [fields]='actionFields' floatLabelType='Auto'></ejs-combobox>
<div *ngIf="skillForm.controls.action.invalid && skillForm.controls.action.touched" class="alert alert-danger">
<div *ngIf="skillForm.controls.action.errors.required"> Book Name is required.</div> |
That gets me close enough.
Thanks for all the help.