Problem with auto-fill

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
digitalphotoworld
User
Posts: 416
Location: Nürnberg/Germany

Problem with auto-fill

Post by digitalphotoworld »

I have set up a table with auto-fill. The filling of the fields works great, with one exception: The field price is field with a value like 12.5 and not 12,5, this results in an error. At the moment it is necessary to change the auto-fill values from . to , by hand.

My locale settings are german with , for decimal and . for thousends separator.


Webmaster
User
Posts: 9438

Post by Webmaster »

AutoFill just place the source field value returned by the database to the target field directly, if you need to format it, use Start Script (see Server Events and Client Scripts in the help file) to subscribe the "autofill" event, e.g. (v10)

$("#x_YourSourceField").on("autofill", function(e, args) {
//alert(args.data); // view the value
args.data = "Your Formatted Value"; // change the value
});

Make sure you change $("#x_YourSourceField") to your field's name. The code also assumes you are working in the Add/Edit page.


digitalphotoworld
User
Posts: 416
Location: Nürnberg/Germany

Post by digitalphotoworld »

Now in Addpage it works like a charm.

If someone has the the same problem, he could use this code:

$("#x_YourSourceField").on("autofill", function(e, args) {
//alert(args.data); // view the value
args.data = args.data.replace( /\./ , "," ); // change the value
});

Attention: This code replace the . to , for EACH autofill-field!!! If you have fields with a . that should not changed, you have to modify it to your needs.


digitalphotoworld
User
Posts: 416
Location: Nürnberg/Germany

Post by digitalphotoworld »

Another question: How could I solve the problem on listpage, e. g. if I use master-/detail?


Webmaster
User
Posts: 9438

Post by Webmaster »

Select by $("[data-field=x_YourSourceField]") instead. (Requires v10.0.1.)


digitalphotoworld
User
Posts: 416
Location: Nürnberg/Germany

Post by digitalphotoworld »

The code above works fine in listpage (Gridadd), but not with Master-Detail Add (as Detail). How could I resolve the problem?


danielc
User
Posts: 1599

Post by danielc »

Are you put the code in Add/Copy Page (in Client Scripts->Table-Specific) instead of List Page for your master/detail add?


Post Reply