This is a migrated thread and some comments may be shown as answers.

Foreign key column with web api and grid

1 Answer 75 Views
Grid
This is a migrated thread and some comments may be shown as answers.
chris
Top achievements
Rank 1
chris asked on 26 Aug 2014, 03:03 PM
Hi,

In the foreign key example the foreign key data used for the dropdown is obtained from the ViewData.

However, with a Web API binding ViewData is not accessible from the web api controller.

What is the best practice approach in this situation?

Thanks

1 Answer, 1 is accepted

Sort by
0
Alexander Popov
Telerik team
answered on 28 Aug 2014, 08:49 AM
Hi Chris,

I am not sure I understand you correctly. Basically, it is the WebAPI controller that should be accessible from the Controller that is responsible for displaying the View where the Grid is initialized. The idea is to fetch the data from the WebAPI and store in in a ViewData collection, so it is available during the Grid's initialization. It is possible to populate the columns.values array (i.e the ForeignKey data) after the Grid has been initialized, but that requires some not so elegant workarounds to be used in order to have a properly working filter menu.

Regards,
Alexander Popov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
chris
Top achievements
Rank 1
Answers by
Alexander Popov
Telerik team
Share this question
or