Client side event

This public forum is for user-to-user discussions of ASP.NET Maker. Note that this is not support forum.
Post Reply
dire
User
Posts: 41

Client side event

Post 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?


Webmaster
User
Posts: 9425

Post by Webmaster »

  1. 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
  2. To calculate when the values are changed, use the "change" event. Make sure that you have re-generated the file "userevt.js"

dire
User
Posts: 41

Post 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


motfs
User
Posts: 258

Post 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);
}


dire
User
Posts: 41

Post by dire »

Hello,

I have used exactly what you wrote down and, event doesn't fire. No alert is displayed


Webmaster
User
Posts: 9425

Post 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:

  1. 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
  2. To calculate when the values are changed, use the "change" event. Make sure that you have re-generated the file "userevt.js"

dire
User
Posts: 41

Post by dire »

Yes, I change the value, the event won't fire at all. No matter What I do.


Webmaster
User
Posts: 9425

Post by Webmaster »

It should work. What version did you use? Make sure that you are using the latest version (2017.0.5).


dire
User
Posts: 41

Post by dire »

Yes now works. The problem was I just forgot "}" in one user event code.


Post Reply