Client side event

This public forum is for user-to-user discussions of ASP.NET Maker. Note that this is not support forum.

Client side event

Postby dire » Mon Sep 25, 2017 8:04 pm

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?
dire
 
Posts: 34
Joined: Mon Sep 26, 2016 7:53 pm

Re: Client side event

Postby Webmaster » Tue Sep 26, 2017 9:37 am

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"
Webmaster
 
Posts: 10733
Joined: Fri Aug 06, 2004 5:59 pm

Re: Client side event

Postby dire » Tue Sep 26, 2017 2:44 pm

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
dire
 
Posts: 34
Joined: Mon Sep 26, 2016 7:53 pm

Re: Client side event

Postby motfs » Wed Sep 27, 2017 9:30 am

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);
}
motfs
 
Posts: 710
Joined: Tue Sep 08, 2015 4:55 pm

Re: Client side event

Postby dire » Wed Sep 27, 2017 12:41 pm

Hello,

I have used exactly what you wrote down and, event doesn't fire. No alert is displayed
dire
 
Posts: 34
Joined: Mon Sep 26, 2016 7:53 pm

Re: Client side event

Postby Webmaster » Thu Sep 28, 2017 11:28 am

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"
Webmaster
 
Posts: 10733
Joined: Fri Aug 06, 2004 5:59 pm

Re: Client side event

Postby dire » Thu Sep 28, 2017 12:01 pm

Yes, I change the value, the event won't fire at all. No matter What I do.
dire
 
Posts: 34
Joined: Mon Sep 26, 2016 7:53 pm

Re: Client side event

Postby Webmaster » Fri Sep 29, 2017 9:43 am

It should work. What version did you use? Make sure that you are using the latest version (2017.0.5).
Webmaster
 
Posts: 10733
Joined: Fri Aug 06, 2004 5:59 pm

Re: Client side event

Postby dire » Tue Oct 03, 2017 6:23 pm

Yes now works. The problem was I just forgot "}" in one user event code.
dire
 
Posts: 34
Joined: Mon Sep 26, 2016 7:53 pm


Return to General Discussion (ASP.NET Maker)