-
Hi Barry
We get the idea thanks. That uses field display values rather than table data. In a tablet scenario that makes sense.
Done that way, it would be easy to change a single field value in a single call. What about bulk changes of several field at the same time on the serverside?
Wish we coud make out the text clearly in the screenshot but looks like you are using + or * chars around the variable ie + var + or maybe * var * with something outside that. We've spent all day trying to guess the syntax !!
Is the new example in RC54? Can't see any of the normal example apps in this build. What have you called it and we will search the hard drive.
Cheers
Simon
-
It's in the build as I said. Example_pclookup
Read the code if you cant read the screenshot. It's basic JavaScript adding strings together just as you would do in your VFP code.
Changing multiple fields is clearly just a repeat of the statement that sets the text of the field based on the JSON object returned from the getAddressDetails() server side proc. If you follow the url I pasted in as a comment it will let you subscribe to their API for looking up address details for a given post code.
You can pass complex objects back to the client from the server using json_encode() and reference the members of the object in the client as I demonstrate in the example code.
As has already been explained you can either update the cursor or update the field in the UI which will result in the cursor associated with the controlsource being updated on the server when the section is saved.
Run the example and read the code you will learn from that.
-
Hi Barry
Works well - thank you. We would never have found the right syntax by trial & error.
One question... when we change the value of the textbox, is there a way to commit the changes other than writing the data separately for each field using cursorname.setData("fieldname", newvalue)?
When we call Lianja.get("pagen.sectionn").save() or Lianja.get("pagen.sectionn").refresh() the data reverts to the old values.
Can we commit either the section or the page or the lot in a single command?
Cheers
Simon
-
2 Attachment(s)
See screenshots below.
As I mentioned previously. You can save() the section or update() the underlying cursor.
You are probably seeing data reverted back in desktop as you are not in "edit" mode on the section.
Attachment 2035
Attachment 2036
-
Thanks Barry
Something is not right here...
Runtime and in edit mode (manually from bottom toolbar). Page set to full page edit
Lianja.getCursor("cust").update(); - still reverts when you press save on bottom toolbar
Lianja.get("page2.section2").save();
Error: Method 'save' undefined on this object
and to ensure it's not a case issue
TypeError: Result of expression 'Lianja.get("page2.section2").Save' [undefined] is not a function.
Don't know why because "save" is a method in the documentation
The only way we can get it to save is :
var cust = Lianja.getCursor("cust");
cust.setData("adl1", addrDetails.adl1);
cust.setData("adl2", addrDetails.adl2);
etc
So we can't update the cursor and we can't save the section. Is there some "master edit mode" we have to be in first? Is the edit button on the bottom toolbar not enough?
What are we missing?
Cheers
Simon
-
Normally you "edit" from the form action bar and "save" or "cancel" from there.
Normally you don't need to work at a low level writing in JavaScript as Lianja does it all for you.
save() on a section when hand coding javascript was not exposed. It is in the latest build as is cancel().
Try the example i provided to you. If it works there then study the code I provided.