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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to use edit template to edit foreign key column?

Platform: JavaScript |
Control: ejGrid |
Published Date: January 17, 2018 |
Last Revised Date: January 17, 2018

 

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

 

JS

 

 

 

 

MVC

 

 

ASP

 

 

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.

 

  

ADD COMMENT
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.

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