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

Showing additional columns/tables for lookup columns

1 Answer 37 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Derek
Top achievements
Rank 1
Derek asked on 12 May 2010, 12:25 AM
Looking for an idea about how to structure this. We have three related tables, Department, agency and program. Program relates to agency via FK, and Agency relates to Department via FK. We'd like to have a single Radgrid for editing programs, and it's easy to show the lookup for programs, but we'd like to show the department name, the agency name, as well as an additional field from the agency table. Here's the structure (simplified)

Department
===========
DepartmentID
DepartmentName

Agency
===========
AgencyID
DepartmentID
AgencyName
AgencyType

Program
===========
ProgramID
ProgramName
[other columns....]
AgencyID








We could create a view that contains all columns, but then I lose the automated editing functionality. Is there a way to create this grid, include the department name and the additional field from the agency table automatically, and still retain the Radgrid editing functionality?

1 Answer, 1 is accepted

Sort by
0
Derek
Top achievements
Rank 1
answered on 12 May 2010, 03:29 PM
While it's technically not a RadGrid issue, I've come up with a solution that works at least in this instance.

I knew that TableAdapters built on queries using JOIN statements don't create Insert/Update/Delete statements, and therefore don't support automatic CRUD functions in the grid. However, I discovered that if the tableadapter is built using correlated subqueries, the insert/update/delete statements are built correctly, the additional field values can be shown, but hide nicely when editing or inserting. Then I used a template item with a multi-column dropdown, that includes both department and agency, to deal with selecting. This was surprisingly easy to get working. I suppose I could have used related dropdowns instead of a single multi-column dropdown, but this seems to work well.

I can post an example of the code if anyone's interested in seeing it or facing the same challenge.
Tags
Grid
Asked by
Derek
Top achievements
Rank 1
Answers by
Derek
Top achievements
Rank 1
Share this question
or