Binding the Grid columns display text to dropdownedit's text

Hi, I'm trying to work with the sample


The country model has countryName and countryId.
In the example, he dropdowns' countryParams uses countryName for BOTH the text and the value.
If the underlying data of the grid column is countryId, how do I display the associated countryName in the grid cell rather than the countryId, but still save the countryId (not countryName) when editing.

many thanks
Ron

3 Replies 1 reply marked as answer

BS Balaji Sekar Syncfusion Team February 8, 2021 12:34 PM UTC

Hi Ron, 
 
Greetings from the Syncfusion support. 
 
Based on your query you need to bind the associated value in the grid instead of displaying the field value column. To achieve your requirement we suggest you to use foreignKey Column feature. In this feature we can bind custom data values in Grid column based on field. 
 
For your reference we have shared the Documentation link for more information 
 
 
In the following example, Customer Name is a foreign column which shows ContactName column from foreign data. 
 
Please refer the below code example and sample for more information. 
 
[app.component.html] 
     <ejs-grid #grid [dataSource]='data' [allowPaging]='true' [pageSettings]="pageSettings"  
    [editSettings]='editOptions' [toolbar]='toolbarItems' [allowSorting]='true'> 
        <e-columns> 
            <e-column field='OrderID' headerText='Order ID' width='120' textAlign='Right' [validationRules]='orderidrules' isPrimaryKey='true'></e-column> 
            <e-column field='CustomerID' headerText='Customer Name' width='150' 
            foreignKeyValue='ContactName' foreignKeyField='CustomerID' [dataSource]='customerData' [validationRules]='orderidrules'></e-column> 
            <e-column field='Freight' headerText='Freight' width='100' format='C2' textAlign='Right' editType='numericedit'></e-column> 
            <e-column field='ShipName' headerText='Ship Name' width='170'></e-column> 
            <e-column field='ShipCountry' headerText='Ship Country' width='150' editType='dropdownedit'></e-column> 
        </e-columns> 
    </ejs-grid> 
 
 
 
Please get back to us if you need further assistance. 
 
Regards, 
Balaji Sekar 


Marked as answer

RC Ron Craven February 9, 2021 06:51 AM UTC

Thanks for your help ... much appreciated


BS Balaji Sekar Syncfusion Team February 10, 2021 07:27 AM UTC

Hi Ron, 
 
Happy to hear that an issue has been resolved in your end. 
 
Please get back to us if you need further assistance. 
 
Regards, 
Balaji Sekar 


Loader.
Up arrow icon