Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

AJAX Combo LIST ONLY NOT STORED VALUES 11 Dec 2012 15:16 #6011

  • JoomGuy
  • JoomGuy's Avatar Topic Author
  • Offline
  • Moderator
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
Hi all,

Just wondering whether anyone had any experience of customising the AJAX combo to only list FK items that didn't already exist in the current table.

Scenario
I have a table productfinishes that stores 2 Foreign Keys - product & finish. When the user selects the product, I want the finish field to display all available finishes (from finishes table) that don't currently exist in productfnishes WHERE product = the user selected product.

To clarify this, products can have multiple finishes and finishes can belong to many products but the combination of product + finish must be unique. I will be handling this at DB level using a UNIQUE index on (product, finish) as per post here: www.j-cook.pro/forum/12-new-functionalit...k-combination-unique

However, I want to make the input stage dummy-proof to prevent the user from being able to enter incorrect combinations in the first place.

Any help on modifications to achieve this would be most welcomed!

Many thanks!

Gez
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!

Please Log in or Create an account to join the conversation.

Re: AJAX Combo LIST ONLY NOT STORED VALUES 11 Dec 2012 17:54 #6018

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
Always the same reflex you must have.

1. Create a new SQL query context (in the appropriate collection model)
2. Receive possible state vars to customize from the caller (to receive important filter vars for your query)
3. From the caller, define 'context' state var , define your parameters to send (state vars)

Now in your example, AJAX is generated in the view file. Function displayAjax(). You will find all there.

Very important :
the state vars need to be sent BEFORE $model->getItems()

I think you have everything that you need.
Coding is now a piece of cake
The following user(s) said Thank You: JoomGuy

Please Log in or Create an account to join the conversation.

Re: AJAX Combo LIST ONLY NOT STORED VALUES 23 Jan 2013 06:10 #6492

  • Rene
  • Rene's Avatar
  • Visitor
  • Visitor
I need to do something similar.
I need the user to select the supplier from a combo, then an ajax event needs to fire to update the style combo with only valid options for this supplier.
I've looked at the code an kind of understand what's happening. I need to know how to trigger the ajax call to populate the second combo box, using your ajax code in dom. If I understand correctly, the ajax call is triggered on load of page?

Update : DOES THIS LOOK OK? SEEMS TO BE WORKING - ADDED THIS TO THE TEMPLATE
jQuery("#jform_supplier").change(function()
{ var supplier = jQuery(this).val();
var vars = {"values": [ "" , supplier ]};
jQuery("#_ajax_style_select1").jdomAjax({
"namespace":"supplierportal.style.ajax.select1",
"vars": vars
});
});

Please Log in or Create an account to join the conversation.

Last edit: by Rene.

Re: AJAX Combo LIST ONLY NOT STORED VALUES 23 Jan 2013 06:42 #6493

  • Rene
  • Rene's Avatar
  • Visitor
  • Visitor
Hi
I also just found that I had to add this to the displayAjax() function in View
$model->setState('list.limit','');
Otherwise, only a few items were displayed.

Update
Oeps I see this should be set in the model :

// Disable the pagination
$this->setState('list.limit', null);
$this->setState('list.start', null);

Please Log in or Create an account to join the conversation.

Last edit: by Rene.

Re: AJAX Combo LIST ONLY NOT STORED VALUES 25 Jan 2013 14:40 #6509

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
This will be solved in 2.0 release.
The problem is because the model context is not properly handled.

In the new coming version, the ajax calls will be much better handled (no possible conflicts with others permanent vars or filters, no conflicts of pagination...)
Coding is now a piece of cake
The following user(s) said Thank You: JoomGuy

Please Log in or Create an account to join the conversation.

Re: AJAX Combo LIST ONLY NOT STORED VALUES 26 Jan 2013 02:49 #6512

  • Rene
  • Rene's Avatar
  • Visitor
  • Visitor
Thank you for your reply. I love your app, thank you so much! At last I understand the ajax code and I managed to do what was required from me by using your ajax code. Working like a charm!

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Time to create page: 0.071 seconds

  Merci d'avoir présenté ce service web générateur de composant joomla. L'interface est très conviviale on a le plaisir du drag&drop et c'est assez rare pour être signalé. Je souhaite que ce projet connaisse un fort succès votre réalisation est méritante.
Yann Gomiero (AFUJ - France)

Get Started