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.
Unfortunately, activation email could not send to your email. Please try again.

How to use edit template to edit foreign key column?

 

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.

 

  

Article ID: Published Date: Last Revised Date: Platform: Control:
8310 01/17/2018 01/17/2018 JavaScript ejGrid
Did you find this information helpful?
Add Comment
You must log in to leave a comment

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.