Using the 'save grid'

hello to all.
Question:

  1. how can you inhibit the possibility of managing (writing and deleting) the custom grid file in ‘save grid’?
    In other words, I would like to prepare some grids with custom columns to display as ‘public’ that should not be overwritten and deleted by those who are working on it, leaving the possibility to manage those additions in ‘rules’ unaltered!

  2. I prepare some custom grid in local, I transfer in production within the respective folders as would scriptcase, but not seen in the list! You can only see those actually stored at the same time! How could it be done?

  3. this would be for NetMake, but I already know that they will not read it and will not accept advice from those who work there daily: put a ‘confirmation’ before deleting the file!

ps: I can not understand what ‘public’ serves if I then can use it like other rules.
If the webapp is used ONLY in a company I will be able to give a further possibility personalizing it by user and public would be for the whole company!
If the app is used by several companies in ‘public’ they should NOT access different companies, otherwise one stores a grid and the other could delete or overwrite it!

Surely I did not understand how to handle it.

Thank you
Ciao
Enrico

Hi Enrico,
Those are very good questions/features. My only luck with using the "Save Grid’ feature has been to check the ‘use rules’. I made one rule that was ‘My Saved Layouts’ and I put the [usr_login] as filter variable. That gives each user a way to make and save layouts.

The second rule I made was ‘Shared By Team’. I use another global variable I have from a table ID that groups people into organizational teams. I figured if someone in a department team finds a layout useful, they could share it with others. The can still delete and mess them up, but only within a smaller team. I agree that having a way to have locked, pre-canned grid layouts would be terrific.

I hope your email does get read by SC. They seem to be actually reading the forum, at least the bug forum, more than ever.
peace,
Jamie

Hi Jamie and thanks for the reply.
I also use rules to diversify saved grids, but my app is used by many companies different from each other. That’s why I would need NOT to delete the saved grids as ‘public’.
Hello and thanks
Peace to you.
Enrico

Since it is important for me to be able to pre-package the same custom grid, at the moment I found this solution, in the hope that NetMake will allow us to activate it within the ScriptCase environment.

The code I share is simpler than words.
In practice, I add a condition to display the ‘public’ option in the drop-down menu that allows you to save the customization, at the line 890 line approximately :


<?php if (strpos($_SESSION['usr_groups'], '900') !== false) { ?>)
...
<?php } ?>

and the condition that does not allow the deletion of the ‘public’ files, at line 949 approximately:


<?php if ($level != $this->Nm_lang['lang_srch_public'] || strpos($_SESSION['usr_groups'], '900') !== false) { ?>
...
<?php } ?>

In my case I allow the whole management (save and delete in the ‘public’ section) only for users of the ‘900’ group (the global variable ‘usr_groups’ contains the list of groups to which the user belongs, eg’ 700,500 'In my case to the 900 group, and only to the 900, belong the administrators of the entire app that is allowed to manage EVERYTHING! Therefore no company-customer will have users who belong to the group 900!).

To do this I run AFTER THE DEPLOY a small script that ‘searches’ in all the folders where the word ‘grid’ appears (my apps are also identified by the type: form, control, grid, etc. eg xxx_grid_yyyy) the file ‘xxxx_save_grid … php’ and make the substitutions.
The ‘c:_deploy_attuale’ folder is my folder where I deploy the deploy!

This is the simple code of a ‘blank’ type app:


foreach (glob("c:\_deploy_attuale\*grid*") as $dirname) {
    $dir1 = $dirname."\\*save_grid*.php";
    foreach (glob($dir1) as $filename) {
        $txt = file_get_contents($filename);  
        $subcloseif = "
<?php } ?>"."
";
        //
        $subopenif1 = "
<?php if (strpos(\$_SESSION['usr_groups'], '900') !== false) { ?>
";
        $searched1 = "<option value=\"publico\"><?php echo \"\" . \$this->Nm_lang['lang_srch_public'] . \"\" ?></option>";
        $newrow = $subopenif1.$searched1.$subcloseif;
        $txt = str_replace($searched1, $newrow, $txt);
        //
        $subopenif2 = "
<?php if (\$level != \$this->Nm_lang['lang_srch_public'] || strpos(\$_SESSION['usr_groups'], '900') !== false) { ?>
";
        $searched2 = "<a href=\"#\" onclick=\"nm_del_grid('<?php echo NM_encode_input(\$save_path); ?>')\" class=\"scGridPageLink\"><?php echo \$this->Nm_lang['lang_btns_dele']; ?></a>";
        $newrow = $subopenif2.$searched2.$subcloseif;
        $txt = str_replace($searched2, $newrow, $txt);
        $txt = str_replace("<option value=\"\"></option>", "", $txt);
        file_put_contents($filename, $txt);
    }
}

I remain in the hope that NetMake will allow us to be able to activate it within the ScriptCase environment, avoiding this operation too!

Ciao
Enrico

Just seen this as I have revisited saved grids… I reported similar problems in 2017, see here:
Grid problem from 2017

I see that they have fixed some of the format problems, but left the most important one about deleting public grids. I hacked a solution then, but didn’t implement it and disabled the save grid function completely. I’m just revisiting it, hence spotting this thread, but have other problems and can’t get the apply grid to work at all. It just throws an unrendered HTML error.

For the record, I resolved the Grid errors. It is caused if the WHERE clause of your SQL held in a global variable includes CRLF for readability. This is saved (as created with the CRLF) in the saved grid’s configuration file. However, the apply grid function reads the saved-grid’s configuration file and interprets the CRLF as an end of the WHERE clause, thus arbitrarily truncating it and creating errors.

The simple solution in my case was to strip the CRLFs from my global variable.

I also tried out the approach for managing the Public saves and preventing deletion, which works like a charm!

NOW if only NM would add the 4 or 5 lines of code to the generator it would make the whole thing work properly. After 6 years, I’m not holding my breath!

1 Like