Two different columns with options
Two different columns with options
Hello!
I have two different columns with options to a same table and same value.
The problem is, when data is load on the second column the value that shows on row is the LastName from the FirstName that is selected on the first column. Should show a different value or empty if is null on database.
Code:
.Field(new Field("OrganicUnit.UserID")
.Options(new Options()
.Table("User")
.Value("UserID")
.Label("FirstName")))
.Field(new Field("OrganicUnit.DirectorUserID")
.Options(new Options()
.Table("User")
.Value("UserID")
.Label("LastName")))
Need to solve this problem.
Thank you
Regards
Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
Replies
Hi,
Can you show me your full PHP for this script, and also the client-side Javascript for DataTables and Editor please? Even better would be if you can give me a link to the page so I can see what is going on.
Thanks,
Allan
I forgot to say that is C#.
I want to made this on server-side if it's possible.
Sorry - I should have seen that it was C#!
If I'm understanding this correctly, you've got two foreign key references to the
User
table fromOrganicUnit
(UserID
andDirectorUserID
).That's absolutely fine, but it means you need two left joins for it as well! One to get the data for each.
(Note that I've aliased the
User
table toDirectorUser
to allow a second reference to theUser
table).You'll also need to add a model for the director user as well:
Should do it - assuming you want the same information from the table for the director.
Then on the client-side, refer to
DirectorUser.LastName
(etc) to display information about the linked director user.Regards,
Allan
Thanks, works well.
Regards.
Awesome - nice one!
Allan