This topic is locked

Guide 15 - Plugin Selection Tree Type

5/21/2021 7:02:47 PM
PHPRunner Tips and Tricks
fhumanes author

How difficult it is to select and use a selection of tree or dependence information between the data! And that there are many information that adjust to this tree-like structure.

The plugin that has been available for a long time and is available on this portal is very good, but aesthetically it is very outdated with respect to the Bootstrap designs that we now use in our projects.

I have found some JavaScript plugins, but none (it is my impression) to be able to integrate them into the PHPrunner plugins.

Objective

Use the JavaScript SearchAreaControl plugin in a Phprunner project.

fhumanes author 5/21/2021

Solution

Demo: https://fhumanes.com/tree.

In one of its configurations the plugin has this image

img alt
To use this plugin in PHPrunner developments I used the method explained in this article.

In the example what I have done is to have 2 tables:

  • A table with all organized registration units in a counseling structure (tree structure)
  • An example of documents where there is a field that is associated with a single registration unit and another field that can be associated with a set of registration units.

The example looks like this

img alt

As we can appreciate there is 3 ways to see/update information regarding documents:

  • The standard or which we would use with the standard phprunner components.
  • The one we could have in the relationship of a single selection of registration.
  • The one we could offer in a relationship of multiple registration units.

I wanted to make it very simple for easy to understand the steps that must be done to use this plugin or another of the same type.

The example is done in phprunner 10.2, so that it is easy for you to open and so you can see that this system is worth for any version 10.x of phprunner.

In the tree directory I have left the CSS and JS file, which requires this plugin.

In the MyCode directory I left the hierrarchy.php file

That does 2 things, mainly:

  • Create the hierarchy of the data from the information stored in the "Keys" table.
  • Create the data structure that the plugin requires, to report the key hierarchy, and even if that key consists (in the case of EDIT) in the registry information.

I have also created 2 Snippet file:

tree_single - for the solution of a lookup of a single value.
tree_multi– for the solution of a various values lookup.

Additionally, I have created code for the JavaScript event onload event that controls when we press the SAVE button and control if we have selected at least one value and copy the plugin selection value to the table field.

As you can see, I have commented on the code to establish the language of the plugin and this is because when I use it, it gives me error the method getSelectedByAttribute. How the plugin, by default responds in English 'en' what I do is put the label 'en' on the constants I want you to answer.

For the snippet to know what is the recipient field of the plugin value and to pass parameters to the snippet I used the Before Display events.

I leave you on my portal, the files to download the project and database and you can try it on your PCs.

For any questions or comment, please indicate it through my email fernandohumanes@gmail.com