Using Chosen Plug-In with a Left Join to Populate Selections

Using Chosen Plug-In with a Left Join to Populate Selections

davepmolldavepmoll Posts: 9Questions: 2Answers: 0
edited September 2014 in Editor

I would like to use the Chosen plug-in to manage the select list. I have the plug in code and all the files.

I am performing a Left Join from the server-side (php) code that will populate my field called "rrrecipeingredientunit.IngredientUnitID." Console gives an error at this line:

initComplete: function ( settings, json ) {
            // Populate the site select list with the data available in the
            // database on load
            editor.field( 'rrrecipeingredientunit.IngredientUnitID' ).update( json.rringredient );

Console gives me an "Uncaught TypeError: undefined is not a function" and I am sure this piece of code needs to be augmented to accommodate the Chosen plugin. And I just don't know enough javascript to figure it out.

Answers

  • davepmolldavepmoll Posts: 9Questions: 2Answers: 0

    OK, I tried this too. The select list just says 'undefined.'

    $(document).ready(function() {
        var editor = new $.fn.dataTable.Editor( {
            
            "ajax": "php/table.rrrecipeingredientunit.php?recipeID=<?php echo $recipeID ?>",
            
            "table": "#rrrecipeingredientunit",
            "fields": [
    
                {
                    "label": "Ingredient Unit",
                    "name": "rrrecipeingredientunit.IngredientUnitID",
                    "type": "chosen",
                    "ipOpts": [ function ( settings, json ) {update( json.rringredient );} ]
    
                },
    

    So can I populate the Chosen field type with "ipOpts" or is it better to use the "initComplete: function ( settings, json ) " with an update function?

    Either way, I would still need to know the proper syntax.

  • davepmolldavepmoll Posts: 9Questions: 2Answers: 0

    I am really hoping someone can help me out. Please. :)

    I am following this example here:

    http://editor.datatables.net/manual/php/joins

    But I want to use the Chosen plug-in on my populated drop down select list. I can get Chosen to work if I manually enter the select field using "ipOps" but that won't work for me long-term.

    I am sure someone else has used the Chosen plug-in to do this. I just need a little help, guidance, suggestions.

  • davepmolldavepmoll Posts: 9Questions: 2Answers: 0

    I'm a moron. :(

    The Select plug-in is much more suited to this. That's all I needed to do.

    Anyone else who finds this thread . . . . use the Select plugin instead.

  • allanallan Posts: 61,822Questions: 1Answers: 10,129 Site admin

    Good to hear you got it sorted out :-)

    Allan

This discussion has been closed.