Startup script for Modal Edit or Add page

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
innovativeshadow
User
Posts: 86
Location: Almaty, Kazakhstan

Startup script for Modal Edit or Add page

Post by innovativeshadow »

Hi all,

  Can anyone please help me.

1) I have got a modula Edit & Add pages, which needs the :

$("#x_Field").change(function() { .... to be working, But I cannot figure out where to write the script for modula. if I write in Add or Edit pages its not working.

2) Also with inline edit, if I use a return FALSE, in row_updating events, it is showing up all the columns that I hided using the List -> page load script. what is the reason and how to make it not to show the hidden columns if the script returned an update error?

Thank you.


arbei
User
Posts: 9372

Post by arbei »

You can add your code in the "Client side events" of the Edit Tag of the field then try again.

Read help file topic: "Project Setup" -> "Field Setup" -> "Client side events (for Add/Copy/Edit/Search)" for more information.


innovativeshadow
User
Posts: 86
Location: Almaty, Kazakhstan

Post by innovativeshadow »

Hi Arbei,

           Thank you for the reply.

          "Client side events"  are working when an edit page is used, but for inline Edit and Modula Edit, the script is not working.

kirondedshem
User
Posts: 642

Post by kirondedshem »

$("#x_Field").change(function() { .... to be working.
NOTE: if the field has auto fill settings it might override your cutom onchange events
1.If you are using a custom script where you get and assign values by referencing your fields with the "x_fieldname" method. then Try attach the event handler directly on the field settings that way it can be called in normal add,edit, modal add,edit, grid add/edit, inline add/edit forms,
go to field setiing of x_field->client side scripts->click el-pse button and your put implimentation here something like, its all jquery here
{ // keys = event types, values = handler functions
"change keyup": function(e) {
//get all fields on the form
var $row = $(this).fields();
//get numbers
var st = $row["field1"].toNumber() ;
//get normla values
var st = $row["field2"].value() ;
//set value
$row["field3"].value(st);
}
}

and ensure you have not other clients scripts messing up at some point, you can inspect page and got o console log to see why they are not working
see the demo project orderdetail table or help menu for more on this

2) Also with inline edit, if I use a return FALSE, in row_updating events, it is showing up all the columns that I hided using the List -> page load script. what is the reason and how to make it not to show the hidden columns if the script returned an update error?

-You can hide a field form inline edit by unselecting it on the show in list section of field settings.
OR
-You can also hide a field from inline edit by setting visible = false on the list page_load
$this->Field->Visible = FALSE;

with any of the above set, the Field will not even be available in row_updating events(I've tested this),
So how are you hidding it


innovativeshadow
User
Posts: 86
Location: Almaty, Kazakhstan

Post by innovativeshadow »

Hi kirondedshem,

                      Thank you for the reply.

                      I am hiding the field using, Server event -> Table Specific -> List Page -> Page_load: 	$this->FieldName->Visible = !$this->IsAddOrEdit();

                      Because I want the Fields to be visible while in list page but not when user edits or adds, the data, as those other fields will be updated by another user.

                    With regard to Point 1, it worked, thank you guys, I messed the code, I just reviewed the code again and it worked fine.

kirondedshem
User
Posts: 642

Post by kirondedshem »

since page load is likely not called when row_updating error occurs(not sure), you should move code to a event that your are sure is called during such atime.
So move code to page_datarendering seems to work


innovativeshadow
User
Posts: 86
Location: Almaty, Kazakhstan

Post by innovativeshadow »

Thank you very much kirondedshem,

Worked like a charm!


Webmaster
User
Posts: 9427

Post by Webmaster »

I am hiding the field using, Server event -> Table Specific -> List Page -> Page_load: $this->FieldName->Visible = !$this->IsAddOrEdit();

$this->IsAddOrEdit() is true when the list page is in add/edit mode (inline add/copy/edit, grid add/edit), BUT NOT when performing the insert/update. To check for the insert/update, also check:

  • inline add/copy: $this->IsInsert()
  • inline edit: $this->IsUpdate()
  • grid add: $this->IsGridInsert()
  • grid edit: $this->IsGridUpdate()

Post Reply