How can I display more than one field of a lookup table (in addition to the item name in a dropdown)

How can I display more than one field of a lookup table (in addition to the item name in a dropdown)

mike92117mike92117 Posts: 40Questions: 12Answers: 1

I have a datatable where I’m using the editor with templates because I have a somewhat complicated form. I’m even using tabs with the editor so it's already pretty customized.

My basic database table has IDs for two other tables (lookup tables) where I want to have the user select from a dropdown or listbox control (look-ups). But it is very helpful that once the user has selected the desired item, it displays on the form other fields of the lookup table as this will help the user choose which one he wants. The description of the item is not often enough information.

For example, if it was a list of cars, it might be useful to know the horsepower and that would be displayed in a label on the form when the user clicks the lookup item. As he selects a different lookup item, the label updates with the new selected car’s engine horsepower.

Not sure exactly the best approach to do this.

This question has accepted answers - jump to:

Answers

  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin
    Answer ✓

    dependent() is going to be your friend here. What I would suggest is having a bunch of readonly fields that show the extra information based on what is selected. The dependent() callback / data would set the fields that should be visible and also the data to show in each one.

    Allan

  • mike92117mike92117 Posts: 40Questions: 12Answers: 1

    I figured that was one likely solution. I was a bit hesitant as it seems the user selecting an item and and then changing to another item, etc., each time would result in a call to the server to get the extra fields.

  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin
    Answer ✓

    That is correct. Unless you have the data for the other fields cached locally - in which case you can use dependent() with its callback function and get the local data.

    If you don't have it locally though, then it would need to hit the server to get the new values.

    Allan

  • mike92117mike92117 Posts: 40Questions: 12Answers: 1

    thanks Allan!

Sign In or Register to comment.