Visual Builder

Get Involved. Join the Conversation.

Topic

    Ameur Baccoucha
    How to create a REST master details tables ?Answered
    Topic posted June 14, 2019 by Ameur BaccouchaSilver Medal: 2,000+ Points, tagged REST, Web 
    40 Views, 15 Comments
    Title:
    How to create a REST master details tables ?
    Summary:
    I wanna to create a page with two tables when i select a row from the first the second one change display values
    Content:

    Hi everyone ,

    first of all, i am new with VBCS so don't blame me if that look easy cheeky

    I did whatch this tuto of ShayJDev and do it but i doesn't work for me.

    https://www.youtube.com/watch?v=oXu37_d_Rx4

    I have a table that contain customers information and from that table i wanna to display the contacts of a customer when i select it in another table.
    Everything work fine but one i click a row nothing happned to the second table.
    you find attached the filterCriterion json
    In the event a added a fire notification to show the id of the row clicked and which is the same in customer row of the second table.
     
    Image:
    Code Snippet:

    Best Comment

    Shay Shmeltzer

    If you have a REST endpoint that accepts a parameter (master id) and fetches all the children for a master then you don't need additional coding.

    You just add an event on the row selection that invoke that endpoint that fetches the right children based on the parameter.

     

    Comment

     

    • Shay Shmeltzer

      Check the network monitor in your browser's dev tools to see how is the REST call that fetches the second table is formatted.

      Does it have the correct q parameter at the end?

      (More on using the network tab here - https://blogs.oracle.com/vbcs/debugging-and-troubleshooting-visual-builder-logichttps://blogs.oracle.com/vbcs/debugging-and-troubleshooting-visual-builder-logic

      • Ameur Baccoucha

        the rest call does not have any parameter it is the same as get many ( "/contact")

        my api does not allo sending query at the end but i can use an parameters like id to invoke a speecific contact

         

        • Shay Shmeltzer

          This seems to indicate that your filter criteria is not being passed to the SDP that populates your table.

          Check the console log to see that your action chain is actually invoked, and that the right values are passed to each step.

          Also make sure that in the filter criteria the $chain.variables.firstSelectedRow.data._id is marked as an expression and not a static value.

           

          • Ameur Baccoucha

            The API i use should accept query parameters ?

            what i see in the console that the variables are ok 

            yes the $chain.variables.firstSelectedRow.data._id is marked as an expression

             

            • Shay Shmeltzer

              Are you using Business Objects as the source of data or some random REST service.

              From the log it seems that your value is not translating properly, make sure that you haven't surrounded it with "" in the definition.

              Also, since that video was recorded we added direct access to the row data as an input to the action - it should look something like this:

               

              • Ameur Baccoucha

                I use REST service

                I did delete the "" sround the value 

                this is my console response now in the image

                also the table is not filtred yet 

                this is my filterCriterion json

                {
                 "attribute": "customer",
                 "op": "$eq",
                 "value": "{{ $chain.variables.firstSelectedRow.data._id }}"
                }

                 

                • Shay Shmeltzer

                  If you are using a random REST service - you'll need to define a transform to get it to filter with the filter criteria approach.

                  Or you can instead use this approach to filtering random REST services:

                  Filtering List Results from a REST Service with Visual Builder

                  (assuming that your service has a way to filter what it returns)

                  • Ameur Baccoucha

                    my API does not support filter settings
                    there is a way to do it in the VBCS or I need to change my API to support the q parameters ?

                    • Shay Shmeltzer

                      VB's default functionality relies on the server side providing filtering. That is what the filterCriteria functionality relies on - it sends a request to the server to provide a filtered list.

                      If your server is not supporting this, and you want to do the filtering on the client, you'll have to code that filtering.

                      You can pull all the records into an Array Data Provider (instead of SDP), and then loop over the array to only keep the records you want - populate another array and show that one in the table.

                       

                      • Ameur Baccoucha

                        in this way also it will be if i wanna do the master detail all will be by coding ?

                         

                        • Shay Shmeltzer

                          If you have a REST endpoint that accepts a parameter (master id) and fetches all the children for a master then you don't need additional coding.

                          You just add an event on the row selection that invoke that endpoint that fetches the right children based on the parameter.

                           

    • John Ceccarelli

      If you're using a REST service, how did you define it? By Endpoint or By Specification? If By Endpoint you'll need to register the transforms for enabling filtering and sorting.