how to make an editor with only select controls in the add form

how to make an editor with only select controls in the add form

DiabloRitoDiabloRito Posts: 11Questions: 3Answers: 1
edited December 2016 in Free community support

Considering the tables below:
table:staff
id----------------- +first_name---------------------+ last_name
1------------------+first_name1--------------------+ last_name1
2------------------+first_name2--------------------+ last_name2
3------------------+first_name3--------------------+ last_name3

table dep
id----------------- +name
1------------------+dep1
2------------------+dep2
3------------------+dep3

table staff_dep
first_name--------------------+ last_name +------------------ dep_name
fist_name1--------------------+last_name1+------------------dep1, dep2
fist_name2--------------------+last_name2+------------------dep1, dep3

I can display them all. and i can edit them all which is good.
Well except for the third table there is a problem.
If I try to add a new relation I got checkbox for departments which is good,
but i got text fields for the first name and the last name :( :( :(
that means that instead of creating a relation between existing data,
it creates a new staff member and a relation for it :( :( :(
I want a select control for staffs (displaying id, first_name, and last_name as one select option ) and checkboxes for departments.
somethings like this:

Add a new relations:
_____________________ __ __ __
|__select a staff______|| || dep1 || dep2 |_| dep3
|1 first_name1 last_name1|
|2 first_name2 last_name2|
|3 first_name3 last_name3|
|_____________________|

Should I have a special Model ? what type of initialization should i use for javascript / C# code ?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,971Questions: 1Answers: 10,160 Site admin
    Answer ✓

    It sounds like you want to use a left join. There is an example of that here (the running example is PHP, but the .NET download includes a similar example).

    Allan

  • DiabloRitoDiabloRito Posts: 11Questions: 3Answers: 1

    Hello Allan,

    You are right All i nedded was left join.
    I saw the example before, and it's not what i needed. that's why i created this topic.
    When i looked again the example of left join. I figured out how it should be done
    instead of starting from the table staff, and joining the table dep (as in the example)
    I started from the table staff_dep and i did two left joins
    the result was what i wanted: 2 select options, one for staffs, the other for deps.

    Regards

  • allanallan Posts: 61,971Questions: 1Answers: 10,160 Site admin

    Super - thanks for posting back! Great to hear you've got it working now.

    Allan

This discussion has been closed.