Technical Solution
Example of the aspect of the example that I have made.
So that the example is very simple and the solution can be better understood, what I have done is create a Snippet above the buttons that shows the execution date of the Snippet and the highest value of all the records, from the field "Text1" .
The registrations and editions are made INLINE, so the system does not reload the page and therefore the Snippet is not updated. This is what we are going to solve with the following code.
We are going to need the name of the Snippet that appears in the HTML that PHPRunner generates. You have to follow what the figure indicates.
We are going to create 2 files.
1.- The “ snippet_proj_1.php ” is the snippet code (proper):
`<?php
$rs = DB::Query("select count(*) count from snippet1");
$count = $rs->value("count");
$rs = DB::Query("select max(text1) major from snippet1");
$major = $rs->value("major");
$date = new DateTime();
$date1 = $date->format('Y-m-d H:i:s');
$html = "At the moment, at $date1 we have $count records and the major text is: $major";
echo $html;2.- the " snippet_proj_1 ajax .php ", which is the one that provides the execution context of PHPRunner when the refresh is requested. This can have this same code in all cases.
<?php
require_once("../include/dbcommon.php"); // DataBase PHPRunner
require("snippet_proj_1.php");To request the refreshment I have written JavaScript code in the event "JavaScript OnLoad event".
this.on('afterInlineAdd', function( fieldsData ) {
// console.log("incio del reload");
$.ajax({ // Reload the Snippet
url: 'MyCode/snippet_proj_1_ajax.php',
dataType: "html",
type: "Get",
data: { }
}).done(function (response) {
// console.log("Justo antes de reload de snippet");
$('span[data-itemid="snippet_proj_1"').html(response);
});
});`On line 10 is the name of the Snippet, to search for it by JQUERY and replace its content with the one received from the URL on line 4.
I think it has been very simple and that you will be able to use it in many circumstances.
For any questions or what you need, contact me through my email: fernandohumanes@gmail.com
I leave you the sources of the project so that you can download and customize it on your PC.