Reputation: 185
I have a domain class called Client
with typical attributes (name, surname,
and so on).
There's also a class called PaymentConditions
(which establishes some parameters to calculate the amount that a client has to pay) which have a reference to Client
. A Client
can have many PaymentConditions
.
And finally there's a Payment
class with attributes like paymentDate
, amount
and a reference to Client
and PaymentConditions
.
When I want to register a Payment
I use an Ajax call to retrieve data from the Client
(including the client id) that is making the payment. But the problem is that because of the reference to PaymentConditions
there's a drop-down list with all the payment conditions registered. What I need is to filter the drop-down list items to show only the ones that are related to the retrieved client
.
Can you help me with this?
Thanks in advance!
EDITED: There's an input field in the form where the user has to enter the Client's surname. This input field has implemented the JQuery UI autocomplete feature, so when a Client is selected the PaymentConditions drop-down list must be updated or filtered for the retrieved Client.
Upvotes: 0
Views: 1067
Reputation: 1707
For showing dropdown list grails provides a special select tag-
<g:select name="paymentCondition" //Name you want to send back to server
from="${client.paymentConditions}" //Client wise filtered conditions where client is a passed client instance
value="${client.paymentConditions.id}" //Selected option value to send to server
/>
Or if you want to filter the list out in controller only then you can do-
def client = Client.get(id);
def paymentConditions = client.paymentConditions
Use the way you like according to your implementation. Hope it helps.
Upvotes: 4