We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Essential JS2

Syncfusion jQuery based widgets are no longer in active development. Switch to our pure JavaScript based next generation Essential JS 2 library.

Syncfusion Feedback

How to use edit template to edit foreign key column?

Platform: jQuery |
Control: ejGrid


The Edit template feature of the Grid allow us to use custom editor for a column. When using custom editor, it is our responsibility to tell the Grid, how to read and write in the custom editor using the read and write functions of the edit template respectively.


When using edit template for a foreign key column, the foreign key mapping should be handled externally and the appropriate value should be returned from the read function. 


 Let us discuss how to use an ejAutocomplete to edit a foreign key column.


Grid initialization













The create, read and write functions of the edit template are as follows.



In the above code example, the ejAutocomplete is configured to display CompanyName and return the CustomerID in the read function.


The following is displayed as the output of the above behavior.


Figure: Foreign key column with autocomplete editor 


Batch editing

The read function will different slightly when using batch edit mode in foreign key column. In this case, the read function should return an object with keys text and value, which should contains the text to be displayed in the cell and value to be saved in the grid data source respectively.



You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile