Okay
  Public Ticket #3345880
One to many relationship
Closed

Comments

  • Jeff Margel started the conversation

    I wanted to use your plugin to have the order header listed as the master and the line items as the details.  Alot of our orders have multiple line items.  How is this possible to do with your plugin?  Can you give me an example?

  •  1,819
    Miloš replied

    Hi, Jeff.

    I am sorry but i am struggling to visualise all the details of your use-case.

    Could you please elaborate a bit more,  and if you can provide any screenshots to show us this data structure;

    i presume if i partially understood,  

    that you will have some columns with cells that have multiple lines in them, 

    and that you would somehow like to "separate" those values that are together in same cell,

    something like that?

    But i am pretty sure i am missing something, 

    so if you can elaborate and we will advise.

    If it has any sensitive data, please mark the reply as PRIVATE, for safety reasons.

    Thank you.

    Kind Regards, 

    Miloš Jovanović
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  • Jeff Margel replied

    Hi Miloš 

      For example:  I have an order.  The order has a header and when the user clicks on the order I would like the line items to show in the details

    (Header)  Customer Name - Order Number - Ship To Address

        (Line Item)  Item A - Quantity Ordered - Quantity Shipped - Price

        (Line Item)  Item B - Quantity Ordered - Quantity Shipped - Price

        (Line Item)  Item C - Quantity Ordered - Quantity Shipped - Price

    Such as a parent - child row in a datatable.  

  •  1,819
    Miloš replied

    Hi, Jeff.

    Thank you for this clarification, i think i understand now.

    You would need a use-case to show details in a Master-Details layout,

    but with parent/child relationships from the database data.

    -

    We do not have an easy user-friendly way to achieve this at the moment.

    If you wish to see an easy built-in solution in the future,

    Please feel free to search on our suggestions page

     to see if someone may be already suggested this feature. If you can't see it, feel free to add your suggestion there,  and as more people vote, the feature will move higher on the priority list.

    You can certainly follow our changeLog page if you'd like ( it is also available in the plugin dashboard), where we state any changes/new features/bug fixes during updates;

    and our newsletter, so you're informed about new features, bug fixes, freebies, etc.

    -


    I will share a custom solution idea that our developers sent us with an example,

    and i hope it helps to give you an idea what you could try - if you have coding skills/ or your developer.

    Our support does not provide troubleshooting for custom work,

    but we do our best to share examples when possible.

    -


    First, you need to create that button (master-detail) column in your existing table with Master-Detail add-on and then set a custom page (post) where users will be redirected after clicking on the button.

    Then, on that custom page, you will insert a table created with an SQL query and using placeholders.

    If you have that table in the database then you will use it for creating a new table with an SQL query and placeholders.

    If you create a manual table then you will use the table that is created in the database (you can find its name in the Editing tab under "MySQL name table for editing"). 

    Those database tables have names like wp_wpdatatable_1,wp_wpdatatable_2... (where wp_ is the default prefix of the database table, but on your end, it could be anything, so look for your_prefix_wpdatatable_1...).

    Then, use that table's database name to create a new one with a query. 

    So you will create a new table like this

    SELECT * FROM table_name_from_mysql_name_option WHERE column_name = %VAR1%

    Then on that custom page, you would insert some default column_name value in shortcode like

    [wpdatatable id=1 var1=test]

    Now hooks. You will add this hook in your functions.php of your child theme or theme, depends on what you are using, to filter this var1.

    And then you will use our hook for dynamically updating placeholders:

    function updateVAR1($tableID){  global $wdtVar1;
          // check is set details data from POST, where you'll find all row data
          // from MasterDetail after button click in first table
        if(isset($_POST['wdt_details_data'])){
            $detailsData= json_decode(stripslashes($_POST['wdt_details_data']), true);
        // instead of origin_header you will insert value from your column origin header
        // on Master-dettails docs you will find Instructions how to create custom
         // template (post or page) and below that is shown what is origin header
           $wdtVar1 = $detailsData['origin_header'];
        }
          }
    add_action('wpdatatables_before_get_table_metadata', 'updateVAR1');



    This is the only way because the shortcode is executed before the content on the page or post.

    Like this when the user clicks on the More details button (that you will create with Master-Detail) it will be redirected to your custom page (that you set in MD).

    On that page, you will insert the shortcode of the Child table created from the query and placeholder.

    After loading the page, the column value will be replaced with a placeholder, placeholders will be replaced in the query and you will get a table that is filtered with that placeholder.

    I hope that I haven't confused you with this, but I try to be as detailed as I can so you can understand what and how you can achieve with this.

    -

    We hope that this helps, and as mentioned earlier, this is just an idea to get you started,

    if you have coding skills/or have your own developer, to try a custom solution right now.

    Thank you.



    Kind Regards, 

    Miloš Jovanović
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  • Jeff Margel replied

    Thanks for the reply.  The only issue that causes is that another window opens.  I am looking for it to run in a popup window such as using the popup builder plugin.

    Since the shortcode takes a %val1% I was thinking of creating a button (the pop-up window can itself be called by a shortcode).  That would grab the order number and pass this on and open the popup. Would there be any javascript that I could run to pull the order number value from the row the user clicked on and pass this onto the wpdatatables shortcode in %val1%?

  •  1,819
    Miloš replied


    Hi, Jeff.

    I can see what you mean,

    but for this particular use-case of making the custom button for a pop-up,

    and grabbing the order number, to pass it as %VAR1% placeholder for the table shortcode;

    at this time we do not have any working examples,   i am not 100% sure if that is possible.

    We will do our best to create any kind of workaround/example in the future,

    but right now our developers still did not have time to try anything like that.

    -

    If you wish to see a built-in solution for this use-case, you can make a development suggestion.

    Please feel free to search on our suggestions page

     to see if someone may be already suggested this feature. If you can't see it, feel free to add your suggestion there,  and as more people vote, the feature will move higher on the priority list.

    You can certainly follow our changeLog page if you'd like ( it is also available in the plugin dashboard), where we state any changes/new features/bug fixes during updates;

    and our newsletter, so you're informed about new features, bug fixes, freebies, etc.

    -

    For trying a custom solution right now,

    I'm afraid we unfortunately do not have any advice how you might start,

    it will require a completely custom solution.

    You can research online resources such as Stack Overflow to see if any user made a similar solution,

    and you have access to browse our available hooks in the Documentation section for Developers here;

    if you try any hook , and if it does not behave as expected , let us know and our devs can try to advise.

    Thank you.

    Kind Regards, 

    Miloš Jovanović
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables