Page 1 of 1

How to keep Changings in TableName_View.php file Permanently?

Posted: 2020-10-24 12:59
by mohamed
Hello,

I am able to edit the Internet_view.php file to have both:
- add the currency sign "USD"
- and change the number format to have a Comma (1,000) and Two Decimal Placed

but the problem, such changed get overwritten, whenever I re-generate the project files, i.e., I must configure the above again in the Internet_view.php


$totalPrice = "USD ".number_format[/color]("$row[0]",2,".",",");
$sumRow .= "<td class=\"Internet-Total text-right\">{$totalPrice}</td>";
$sumRow .= '<td class="Internet-Remarks"></td>';
$sumRow .= '</tr>';

$x->HTML = str_replace('<!-- tv data below -->', '', $x->HTML);
$x->HTML = str_replace('<!-- tv data above -->', $sumRow, $x->HTML);


Is there a way to keep these cahnges not to get changed ?

Re: How to keep Changings in TableName_View.php file Permanently?

Posted: 2020-10-24 13:39
by jsetzer
Did you see the dataFormat options?

AppGini_WMBGe53671.png
AppGini_WMBGe53671.png (30.86 KiB) Viewed 2673 times

I hope this old thread will help:
viewtopic.php?f=11&t=1614&p=13242&hilit ... mat#p11142

Re: How to keep Changings in TableName_View.php file Permanently?

Posted: 2020-10-24 16:52
by mohamed
Hi jsetzer
Thank you ...

The problem, dataFormat changes the type of the numbers to String, I believe, so it does not let you use the Calculated Field, i.e., you cannot use Calculations nor SUM.

Re: How to keep Changings in TableName_View.php file Permanently?

Posted: 2020-10-24 17:18
by jsetzer
I'm afraid you are right. So maybe, instead of changing overwritable files, you should add hooks/TABLENAME-tv.js and (a) use jQuery to change that sum cell and (b) avoid using calculated fields for calculations mixed with string formatting.

Re: How to keep Changings in TableName_View.php file Permanently?

Posted: 2020-10-24 17:24
by jsetzer
What I mean by (b):
Formatted calculated fields will be overwritten in TV row by row and then lose their format unless you turn it into varchar and format the value in sql.

Personally, I dislike mixing (calculated) numbers and string formatting. In these cases I am usually using after... hook or _init hook for updating numeric fields (not calculated fields). Then I can use dataformat options.

I love calculated fields, but they have their limits. That lazy row by row update in table view is one limit I have faced several times in the past. So I'm using calculated fields very carefully and prefer the hooks way very often.

Re: How to keep Changings in TableName_View.php file Permanently?

Posted: 2020-10-24 17:38
by jsetzer
Reading your question again,
(c) you can make that overwritable file read only. It will not be overwritten. But then changes in project will not be applied to those files. So, whenever you do changes in overwritable files, not hooks files, you will have the same problems. That's why I almost never do this.

(d) There are one or two experienced superheroes around here who often do such string replacements in header or footer hooks. I don't have examples but this could be a starting point.

(e) I have also seen a tip of Ahmed in his Blog where he changes php files at runtime. I think the blog post was about overwriting existing AppGini php functions by string replacements and overwriting core php files.

Re: How to keep Changings in TableName_View.php file Permanently?

Posted: 2020-10-26 09:51
by mohamed
Hi jsetzer,

Noted, will investigate the options and see what to do next.

Again, "Vielen Dank" for your time and valuable thoughts.