Guide 39 – List of data dependent on the master record data |
6/12/2022 4:26:04 PM |
PHPRunner Tips and Tricks | |
![]() Surely, this issue has been discussed in some other article on the Xlinesoft forum, but I was asked by a developer who had spent many days trying to find a solution on the forum and had not been able to find it. It is not easy for me to describe the functionality, I am going to try, and later, I will put some images and a long description to explain it. Goal In an ADD and/or EDIT page, where we are treating the information of the master and details record at the same time, it turns out that there is a list of values in details, which is dependent on a value of the master record and both can be updated anytime. How to fix this dependency? DEMO : https://fhumanes.com/trade Technical solution To explain it and provide an example, I have made an assumption that uses this data model:
What I am trying to simulate is a company that has different warehouses and that in these warehouses there are different products, in such a way that when a delivery note is made, and a warehouse is indicated, only the products that exist should appear as selectable. in said warehouse. On the ADD page it has this form: As you can see, in the master record the Store is indicated and when it shows the list of products it only indicates the products that exist in that store.
Surely the first idea is to create all the logic and control of the products in JavaScript, but that has not been the solution that I have adopted in this example. What I do is, through Ajax , pass the "Store" data to the server to create a session variable with this data and thus make the list of products conditional on the value of said session variable. Important: In the designer option, on the EDIT page, the standard button “ Edit selected ” has been added, to later use it in the programming logic.
To use this session variable, the Lookup is configured in this way:
I leave you all the code of the example so that you can install it on your PC and perform all the examples you need, I hope you like the solution and if you have any questions, contact me through my email fernandohumanes@gmail.com |
|
T
|
Tim 6/15/2022 |
Why wouldn't you just use the ASPR SQL variables? In the "Where" of the lookup just put: id_trade_store = ':master.id_store' No need to create a session. |
![]() |
Sergey Kornilov admin 6/15/2022 |
I have the same question as Tim, how is this different from using SQL variables where you can refer to master table data as well. |
![]() |
fhumanes author 6/18/2022 |
Hi @Tim, Perhaps, you have only read the text of the article and you could not try and see the code of the example. I have a hard time describing the examples so that they understand each other well and from there, perhaps, it is where the doubts you have about the solution. In my example, both records (master and details) are updated at the same time and that is why (because the data is not consolidated in the server) therefore your solution is not valid. Your solution can serve if the "master" and "details" records are updated separately. Since in my example we already have the data, etc. You can download it and change it to verify that your proposal does not work. Cheers, |
![]() |
fhumanes author 6/18/2022 |
Dear @Sergey, I was very surprised by your doubts to the solution, because being is always very accurate in what you say (you are the creator of the solution). I have tried to explain it to @tim. If at the same time update "Master" and "Details", Tim's proposal does not work. Cheers, |
![]() |
Sergey Kornilov admin 6/22/2022 |
Fernando, there is no need to get defensive. You implemented the solution that is an exact replica of the existing functionality so these are valid questions. Now, your assumpltion about SQL variables is incorrect here. The value of the master record field will be taken directly from the form in case you Add/Edit master-details together. |
![]() |
fhumanes author 6/22/2022 |
Hello, I am very sorry to have given the impression that I am on the defensive. My native language is Spanish and I use a translator to put it in English and it is possible that expressions in one language or another, do not understand the same. I have tried to explain that they are different situations and that my solution implies:
Especially @Tim, sorry if my answer was not adequate. Cheers, |
T
|
Tim 6/22/2022 |
No worries Fernando. I appriciate you translating to my language so I can understand you. I'd hate to see how my troubled english translated to spanish. And I believe you that you've tried the SQL variables solution and it didn't work for you. I don't fully understand why it wouldn't, but I don't need to. Maybe someone (like future me) will come accross a similar problem and realize your solution is exactly what is needed. Thanks for sharing. Thanks, |
![]() |
fhumanes author 6/23/2022 |
Thank you very much @Tim, I have tried your proposal and it has not worked for me. As Sergey indicates that he does work, it is very possible that he is doing something wrong. Cheers, |