Last problem to tackle with the Editor tables and updates

Last problem to tackle with the Editor tables and updates

webpointzwebpointz Posts: 126Questions: 30Answers: 4

Here is my issue.

I have an Editor datatable that lists users. Users login and place orders. In most cases, the user will order ONLY with their own address as the destination.

The user is part of a customer base. For instance, one customer has 100 users and 100 destination addresses.

A regular user will have access ONLY to their own address. An administrator will have access to ALL destinations.

When an administrator adds a new user, they are accessing 4 tables (user, customer, address, level).

In the user table, there is a field called addresses (varchar). In the old application, adding a user would show a multi select list with the id's for the values. If more than one address was selected, the field would contain a comma delimited list of address ids.

This is the last piece of my application and it's critical to have this functionality, however, the old application was just straight code and not datatables.

When a user is created, the editor modal has firstname, lastname, email, a customer list box to assign them to a customerid. I need to also show a multi select list box containing the addresses for whatever customer they selected above, then allow them to select "ALL" or one or more selections which would then update the addresses field in the user table.

Conversely, if the user is being updated, I need the address list to highlight the id's they already have.

Is there anyone that can help me? I'm completely lost on this issue.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,863Questions: 1Answers: 10,136 Site admin
    Answer ✓

    Sounds like a perfect use case for the dependent() method. As the customer is selected dependent() would make an Ajax call to the server to get the options to show for the addresses and then update those options.

    You would need to write a little bit of code on the server-side to receive that Ajax request, get the required data and then respond, but dependent() is what I would recommend.

    Allan

This discussion has been closed.