Modify the Report Sample App to include functions (Add, Edit, Delete)?


Guest

Is it possible and can you please modify the sample app "Report" to include these functions (Add, Edit, and Delete) specific records from the "data.php" and "data.json" files after the app has been compiled and run? I want the end user to be able to modify (Add, Edit, and Delete) specific records from the "data.php" and "data.json" files in addition to what it currently does already, which is the ability to retrieve certain records from the "data.php" and "data.json" files via the search query after it has been compiled and run.


DecSoft

Hello CIS,

Certainly we can prepare the required stuff to not only retrieve and show information from a webserver, allowing to add and edit information too, but probably this is out of the scope of the Report app sample. Maybe we can prepare an specific app sample to doing something like you wanted, however, in the meanwhile, note what are the required stuff in order to do something like that:

1º We firstly need a webserver capable to receive HTTP GET and POST requests and also to store the information in some kind of database like MySQL, for example.

2º We need to prepare some kind of API accesible by HTTP calls in URL like the below ones:

3º We can use a Report control to process and show the JSON data provided by the "get.php" HTTP requests. Note we can add some arguments to the URL in order to retrieve specific information, for example, this URL:

... can produce different results than this other URL:

4º The "edit.php" script can be ready to accept some record specific ID, for example:

The above URL can respond with a ready to parse variables list text like these:

We can use the "ParseVariables" action to get the variables from the response and show their content in a couple of Text input controls.

5º The same app view which show that Text input controls can have a Push button to made an HTTP POST request to the same "edit.php" script, providing the updated information of the edited record.

6º In order to add new records to the database we only need the appropiate Input controls and to made an HTTP POST request to the "add.php" script, providing the appropiate record information.

Probably this is not a complete answer since I do not add what you wanted to the Report control, but I tell you how something like that can be made using App Builder. Maybe in the near future we prepare an app sample around this.



DecSoft

Hello,

As an addition to my previous message I want to say than the Report control is very powerful and right now App Builder include four different samples: Report, Report2, Report3 and Report4.

A Report control can be feed using their URL variable. Then the control automagically perform the HTTP request, retrieve the response and prepare the data to be show into the Report table.

Maybe we are a bit confusing with the samples "data.json" and "data.php" files. In fact we can include files like "data.json" in our apps in order to feed a Report control with the file app local URL.

"data.php", instead, is a sample of how the JSON data can provide from a webserver and therefore can be dinamically changed or updated in order to allow our apps to show the latest information.

On the other hand, the Report control can also be feed by using their "Data" variable instead their "URL" variable. And this can be made at least in two ways: load JSON data using an action like "SimpleGet" or prepare our own JSON object using the object related actions.

This last way is particularly interesting because we prepare the JSON object in runtime and therefore such object can contains different information in different scenarios. The App Builder's Report3 and Report4 show to us how to do something like this.

That's all! Hope this information can be useful!

Don't forget to play with the App Builder's app samples!



Guest

Hello,

Yes i have extensively played with all 57 app samples in the App Builder including Report, Report2, Report3 and Report4 as you suggested. In fact, i am very confused with your latest message about "SimpleGet". In fact i have modified the code in the sample app "Report" to this:

What i really would like is to be able to allow the end user to modify (Add, Edit, and Delete) specific records locally (http://127.0.0.1:9999) from the "data.php" and "data.json" files in addition to what the Report sample app currently does already, which is the ability to retrieve certain records from the "data.php" and "data.json" files via the search query after it has been compiled and run. After i get that working locally first and fully functional, then i will connect it to an MySQL database in the Microsoft Azure Cloud via their "Mobile Services" feature. I can and have already compiled and ported the Report sample app to an Xcode project via Apache Cordova CLI where it works locally as a native iOS platform via the simulator just fine so far.


DecSoft

Hello CIS,

First of all, note than the "InputBox" action callback must be an app function, not an action like "StrReplace" as you write. Take a look at the InputBox app sample for more information. On the other hand, probably you need to decide what action execute next: "HttpExecute", "SimplePost" and "SimpleGet" probably cannot be called like you write above.

If you choose to use the HttpClient control to made an HTTP POST it's ok, but you no need to call "SimplePost" at all. On the other hand, "SimplePost" do not offer any feedback, then maybe it's not the right action in your case. Finally you call the "SimpleGet" action, but, again, probably you no need to do something like that CIS.

You can play with the app using a local webserver (*), just remember that if you want to use PHP and MySQL these stuff must be available and running in the local webserver too. We need to think our app is a act like a web page in these scenarios, and therefore we must made the appropiate HTTP GET and POST requests. We can need more or less calls, the Report control or others, depending of the app we made.

If you start with the app I can help you in some particular points when you need! In other case I can't promise when I a possible app sample like you wanted can be ready since I am very busy right now with other App Builder stuff.

(*) Remember that App Builder debugger starts an HTTP local server, then, if you need to work with other local server you must use different ports. By default App Builder uses the 9999 port and this can be changed in the program options dialog from the Menu -> Edit -> Program options.



Guest

Okay, i have created from scratch these 5 PHP files in Visual Studio Code and placed them in the folder directory of Report where "data.php" is located.

File #1 (Config.php):

File #2 (Add.php):

File #3 (List.php):

File #4 (Edit.php):

File #5 (Delete.php):

With that in mind, how can i incorporate all this code (5 PHP files) that i have created from scratch into the Report app sample in App Builder via a detailed step by step instruction from you. I have installed fully the MySQL Server 5.7.8 and all of its associated products such as Workbench 6.3.4, Notifier 1.1.16 and so forth


DecSoft

Hello CIS,

I think your PHP do not look what we can expect. For example, your PHP scripts produce HTML code, which is something that your app do not expect. Your app provide all the required HTML, you no need to worry about it in the PHP scripts. These scripts must "act" when are requested and must responde with the appropiate data. No more.

You no need an HTML form to send information to your PHP scripts: you must use the Input controls what you need and then use the Http client control to perform the appropiate HTTP POST request. On the same way, you no need to list your database data by output it from PHP scripts. Your scripts must return JSON data that the Report control can parse and show automatically for you.

I am very sorry because this app sample are not trivial at all, probably take me several hours, and currently I am very busy with other project areas. Again, try to understand what you need and ask here for help when you needed. I am very sorry but I can't say other thing at this time. Just remember:

1º add.php - Need to receive POST data and their response can be, for example, just an "OK" or "Fail", in order to understand from our app the data has been added.

2º edit.php - Need to receive POST data and their response can be, again, just an "OK" or "Fail", in order to understand from our app the data has been updated or not.

3º list.php - Only need to return the appropiate data as a JSON object. This script must be very similar to the "data.php" you can found in the current app samples. That JSON object is parsed and show by the Report control.

4º delete.php - Need to receive POST data and their response can be the same than "add.php" and "edit.php".

On the other hand, remember we need to enable "CORS" requests in our PHP scripts. You can view how by read the "data.php" refered above and included into the Report app sample. This may are not needed for the local web served files (probably not) but "CORS" must be enabled for our PHP scripts when use a remote server.



DecSoft

Hello CIS,

Better late than never, App Builder include right now a new Database app sample wich show us how to use a Report control along with HTTP Client controls to retrieve and list information from a remote database and also update, delete and insert new information in such database. To this app sample we use PHP and MySQL in the server, and the PHP scripts and the MySQL database estructure are included in the app sample too.


Todo el mundo puede leer el foro de soporte de DecSoft para aprender del mismo, sin embargo, sólo los clientes de DecSoft pueden abrir nuevos hilos. Compre una o más licencias de productos de DecSoft y obtendrá este y otros beneficios.

Este sitio utiliza "cookies" útiles para almacenar sus preferencias.

Bien. Ocultar esta nota. Obtener más información.