This topic is locked
[SOLVED]

 Custom Button for each row

11/22/2012 4:26:43 AM
PHPRunner General questions
S
StefanoF author

Hi.

I'm new to PHP and therefore new to PHPRUNNER(ver. 6.2) and Javascript.
I've a List page where each row represent an activity which has it's own STATUS.

I've added a column where I've inserted 3 buttons ("SEND","CONFERM","REJECT").
Now, what I would like to do is :

if the row STATUS is "ready" or "rejected", only the "SEND" button will be displayed and if pressed the status will change to "sent", and obviously the "SEND" button will be hidden.

If the row status is "sent", only the "CONFIRM" and "REJECT" button will be displayed. If "CONFIRM" button is pressed the status changes to "confirmed" and the "CONFIRM" and "REJECT" button will be hidden. If "REJECT" is pressed the status changes to "rejected", the "CONFIRM" and "REJECT" button will be hidden and the "SEND" button will be visible.
I've searched in the forum/Help and, as I'm new to PHP and JS, I've tried at least to hide one button with the following code document.getElementById('Reject').style.visibility='hidden'; in the JS OnLoad event, but with no result. <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=20332&image=1&table=forumtopics' class='bbc_emoticon' alt=':(' />

Can anyone help me to find the right procedure, event and code ??
Thanks.
Stefano

C
cgphp 11/22/2012

You have to use custom button: http://xlinesoft.com/phprunner/docs/inserting_button.htm
If you want to get the value of fields, use rowData (http://xlinesoft.com/phprunner/docs/rowdata_object.htm) in the "Client before" and "Client after" events
Use the ctrl object to enable or disable the buttons:

ctrl.setDisabled(); //disable button

ctrl.setEnabled(); //enable button
S
StefanoF author 11/22/2012

Cristian, first of all thanks. I felt like lost in the PHP/JS jungle and with your suggestions I feel I can come out of it.
I've followed the manual, added the button and then moved it in the grid.

I've added wrappers to the new button (this bit was missing from my local PHPRunner manual).

So far I've managed to hide the button on a given state.

Now, before proceeding with any update, I've tried to simply press the button and see what happens and I got the error icon on the left bottom corner.

The detailed error message says **"Messagge: 'keys.length' is null or is not an object - Line: 249

S
StefanoF author 11/22/2012



Cristian, first of all thanks. I felt like lost in the PHP/JS jungle and with your suggestions I feel I can come out of it.
I've followed the manual, added the button and then moved it in the grid.

I've added wrappers to the new button (this bit was missing from my local PHPRunner manual).

So far I've managed to hide the button on a given state.

Now, before proceeding with any update, I've tried to simply press the button and see what happens and I got the error icon on the left bottom corner.

The detailed error message says **"Messagge: 'keys.length' is null or is not an object - Line: 249


Cristian, I gave a try with Chrome and Firefox and as there was no error, I added on the "ONSERVER" event the following code :

$result['record'] = $button->getCurrentRecord();

$result["txt"] = $params["txt"].$result['id'];

and on the "ONAFTER" event :

var message = result["txt"] + " !!!";

ctrl.setMessage(message);

This, I thought, should have displayed the record id, but it didn't.
Stefano.

C
cgphp 11/22/2012

Enter this code in the "Server" section:

$data = $button->getCurrentRecord();

$result["txt"] = $params["txt"].$data['id'];



and this in the "Client after" section:

var message = result["txt"] + " !!!";

ctrl.setMessage(message);
S
StefanoF author 11/22/2012



Enter this code in the "Server" section:

$data = $button->getCurrentRecord();

$result["txt"] = $params["txt"].$data['id'];



and this in the "Client after" section:

var message = result["txt"] + " !!!";

ctrl.setMessage(message);



Tried on :

  • IE8, no message displayed and I still get the 'keys.length' error
  • Chrome and Firefox, no message displayed

C
cgphp 11/22/2012

Do not drag the button after inserting it but make sure to insert it directly to the grid.

S
StefanoF author 11/22/2012

I did as you suggested, but the result didn't change.
How about the "'keys.length' error". Could that be the problem ? May be the error message comes up only with IE8, but it happens on all browsers ?

C
cgphp 11/22/2012

Did you set a primary key for that table in PHPrunner? Refer to this page: http://xlinesoft.com/phprunner/docs/edit_page_settings.htm. Go to the "Pages" sections, click the "Edit button" and select the primary key for that table.

S
StefanoF author 11/22/2012



Did you set a primary key for that table in PHPrunner? Refer to this page: http://xlinesoft.com/phprunner/docs/edit_page_settings.htm. Go to the "Pages" sections, click the "Edit button" and select the primary key for that table.


Cristian,

so far I owe you at least a coffee!!!

The table has a primary key, but I 'didn't set it on the "PAGES"!!!

Now no error message is shown and finally the "id" is shown!!!
Hoping to be able to continue without bothering you, I really thank you.
Stefano

S
StefanoF author 11/23/2012



Cristian,

so far I owe you at least a coffee!!!

The table has a primary key, but I 'didn't set it on the "PAGES"!!!

Now no error message is shown and finally the "id" is shown!!!
Hoping to be able to continue without bothering you, I really thank you.
Stefano


Cristian, once the button is pressed, as the STATUS is changed , I need to hide it. How and where(EVENT) can I do it ?
Thanks.

S
StefanoF author 11/23/2012



Cristian, once the button is pressed, as the STATUS is changed , I need to hide it. How and where(EVENT) can I do it ?
Thanks.


Cristian, I found the solution on the Forum.
window.location.reload()
Thanks anyway.