foreach tableA in edit(field type select) when in tableB.js

foreach tableA in edit(field type select) when in tableB.js

t3631867t3631867 Posts: 5Questions: 2Answers: 0

Hi,
the Question is describe in the Attachments,
is any way to achieve?

regards

Answers

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin

    Yes - the select field type has an upload() method that you can use to dynamically assign the options that should appear in the options list.

    Allan

  • t3631867t3631867 Posts: 5Questions: 2Answers: 0
    edited May 2017

    Hi Allen,
    I means is there any way to edit table1
    and select option is table2? (how to access another table in this editor)

    my code example

            db_table='products';   //table1 name
            db_table2='category'; //table2 name
    
            //###this editor is edit table1 
            var editor; // use a global for the submit and return data rendering in the examples
            editor = new $.fn.dataTable.Editor( {
                "ajax": {
                    'type': 'POST',
                    'url': 'php2/join_products.php',//table1
                    'data': {
                       db_table: db_table,
                       //db_table2: db_table2,  // its any way to access table2?
                    },
                },
                // "ajax": "php2/staff.php",
                // "ajax": "php2/join.php",
    
                "table": "#example",
                "fields": [
                    {
                        "label": "productlevel:",
                        "name": db_table+".productlevel"
                    },
                    {
                        "label": "categoryid:",
                        "name": db_table+".categoryid",
                        type:  "select",
                        options: [  // #### I need display table2 in here!!! ####
                            { label: "cat1  (1)",   value: "1" },
                            { label: "cat2  (2)",   value: "2" },
                            { label: "cat3 (3)",    value: "3" },
                            { label: db_table2+".categoryname",   value: db_table2+".categoryname" },   // it's not work !!!!
                        ]
                    },
                    {
                        "label": "productname:",
                        "name": db_table+".productname"
                    },
                    {
                        "label": "productprice:",
                        "name": db_table+".productprice"
                    },
    
  • t3631867t3631867 Posts: 5Questions: 2Answers: 0

    or how to store the join data to a global array?

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin

    You can get the data from table2 using rows().data() and pass that into the update() method I suggested. There is currently no option to display a DataTable in the Editor form. That is something I will introduce in future.

    Allan

This discussion has been closed.