model select object

Hi

There is a way for the selected value to be an object and not the value of the field , I have this configuration

<ejs-dropdownlist
name="radicationBook"
#radicationBookModel='ngModel'
required
[(ngModel)]='document.radicationBook'
[dataSource]='radicationBookDts'
[fields]="{value: 'id', text: 'denomination'}"
placeholder="{{ 'LABEL.RADICATION' | translate}}">
</ejs-dropdownlist>

And when I select an element, the model takes the value of the id, and I need to configure so that the value of the model when it is select be from object.



1 Reply 1 reply marked as answer

DR Deepak Ramakrishnan Syncfusion Team October 26, 2021 10:46 AM UTC

Hi Yosviel, 
 
 
Greetings from Syncfusion support. 
 
 
We have validated the requirement in our end . You can use select (Triggers every time when the value get selected) event to get the the respective object mapped to the value selected as we can only map the applicable type to the value property .  Kindly refer the below highlighted code and sample for your reference. 
 
 
 
 
[app.component.html] 
 
<ejs-dropdownlist 
name="radicationBook" 
#radicationBookModel='ngModel' 
required 
[(ngModel)]='radicationBook' 
[dataSource]='radicationBookDts' 
[fields]="{ text: 'denomination'}" 
placeholder="Radication Book" 
(select)="selectHanlder($event)"> 
</ejs-dropdownlist> 
 
 
 
 
[app.component.ts] 
 
 selectHanlder(args){ 
        this.radicationBookObj = args.itemData; 
        console.log(this.radicationBookObj); 
    } 
 
 
 
 
 
 
Also you can refer the below documentation for more details about data binding 
 
 
 
 
Thanks, 
Deepak R. 


Marked as answer
Loader.
Up arrow icon