Page 1 of 1
Client side event
Posted: Mon Sep 25, 2017 8:04 pm
by dire
Hello,
I want to calulate from price and discount into total. There is no error in console. I also tried event type focus and onfocus on chrome, firefox. Calculation doesn't work at all.
Code in field pogoda_produkt_skupaj (Cilent side event) field:
{ // keys = event types, values = handler functions
"focus": function(e) {
var $row = $(this).fields();
var vrednost = $row["letna_premija_neto"].toNumber() * (1-$row["popust"].toNumber());
$row ["pogodba_produkt_skupaj"].value(vrednost);
}
}
any idea?
Re: Client side event
Posted: Tue Sep 26, 2017 9:37 am
by Webmaster
- To set up the value initially, you can use the client side table start up script or server side Row_Rendered server event. Alternatively, just use a Custom Field which can calculate the value (based on the provided SQL) directly
- To calculate when the values are changed, use the "change" event. Make sure that you have re-generated the file "userevt.js"
Re: Client side event
Posted: Tue Sep 26, 2017 2:44 pm
by dire
ok,
userevt.js should be visibile in Chrome Debug Tools->Sources->Localhost->js->userevt.js. In my case I don't see userevt.js, but userfn.js is loaded.
I double checked under Project->wwwroot->js->userevt.js existst, and the code is writen. When I generated project I check userevt.js
Re: Client side event
Posted: Wed Sep 27, 2017 9:30 am
by motfs
Add code to debug if the change event is triggered, e.g.:
"change": function(e) {
alert("trigger_change"); // output message to show if this event is triggered
var $row = $(this).fields();
var vrednost = $row["letna_premija_neto"].toNumber() * (1-$row["popust"].toNumber());
$row ["pogodba_produkt_skupaj"].value(vrednost);
}
Re: Client side event
Posted: Wed Sep 27, 2017 12:41 pm
by dire
Hello,
I have used exactly what you wrote down and, event doesn't fire. No alert is displayed
Re: Client side event
Posted: Thu Sep 28, 2017 11:28 am
by Webmaster
The "change" event will be fired only when the value changes. Did you change the field value after the form is loaded?
As explained:
- To set up the value initially, you can use the client side table start up script or server side Row_Rendered server event. Alternatively, just use a Custom Field which can calculate the value (based on the provided SQL) directly
- To calculate when the values are changed, use the "change" event. Make sure that you have re-generated the file "userevt.js"
Re: Client side event
Posted: Thu Sep 28, 2017 12:01 pm
by dire
Yes, I change the value, the event won't fire at all. No matter What I do.
Re: Client side event
Posted: Fri Sep 29, 2017 9:43 am
by Webmaster
It should work. What version did you use? Make sure that you are using the latest version (2017.0.5).
Re: Client side event
Posted: Tue Oct 03, 2017 6:23 pm
by dire
Yes now works. The problem was I just forgot "}" in one user event code.