redirect page after action ListOption_rendered

im create

function ListOptions_Rendered() {
	$this->ListOptions->Items["send"]->Body = "<a href=\"#\" onclick=\"return ew.submitAction(event, {action: 'send', method: 'ajax', msg: 'Akan mengirim Kedivision Head?', key: " . $this->KeyToJson(TRUE) . "});\">Kirim</a>";
	$this->ListOptions->Items["approve"]->Body = "<a href=\"#\" onclick=\"return ew.submitAction(event, {action: 'approve', method: 'ajax', msg: 'Yakin Akan Approve?', key: " . $this->KeyToJson(TRUE) . "});\">Approve</a>";
	
}

function Row_CustomAction($action, $row) {
$username = CurrentUserName();
$datetime = CurrentDateTime();
	if ($action == "send") { // Check action name
			$rsnew = ["status" => "send","aktorsend" => "$username","senddate" => "$datetime"]; // Array of field(s) to be updated
			$result = $this->update($rsnew, "id = $row[id]"); // Update the current record only (the second argument is WHERE clause for UPDATE statement)
			if (!$result) { // Failure
					$this->setFailureMessage("Failed to Send, ID = " . $row["id"]);
					return FALSE; // Abort and rollback
			} elseif ($this->SelectedIndex == $this->SelectedCount) { // Last row
					$this->setSuccessMessage("Berhasil Send Ke Division Head.");                
			 }
			 return TRUE; // Success
		 }
	elseif ($action == "approve") { // Check action name
			$rsnew = ["status" => "approve","appaktor" => "$username","appdate" => "$datetime"]; // Array of field(s) to be updated
			$result = $this->update($rsnew, "id = $row[id]"); // Update the current record only (the second argument is WHERE clause for UPDATE statement)
			if (!$result) { // Failure
					$this->setFailureMessage("Failed to Send, ID = " . $row["id"]);
					return FALSE; // Abort and rollback
			} elseif ($this->SelectedIndex == $this->SelectedCount) { // Last row
					$this->setSuccessMessage("Berhasil Approve.");                
			 }
		 return TRUE; // Success
	 }     
}

im test on Page_Load:

function Page_Load() {

$this->CustomActions["send"]= new ListAction("send", "send", IsLoggedIn(),
ACTION_POSTBACK, ACTION_SINGLE);
}

not working
I need an automatic redirect to the list page again so that the changed data is visible. What server should I add to the event server? thank you

Use “post” instead of “ajax” so that the action is posted back and the page is reloaded.

From the source code:

@param {string} args.method - “ajax”|“a” (Ajax by HTTP POST) or “post”|“p” (HTTP POST, default)

if(CurrentUserLevel()==3 && $this->status->CurrentValue ==“open” && $this->ak1bln->CurrentValue >40){
$this->ListOptions->Items[“send”]->Body = "<a href="#" onclick="return ew.submitAction(event, {action: ‘send’, method: ‘ajax’, msg: ‘Akan mengirim Kedivision Head?’,ACTION_POSTBACK, key: " . $this->KeyToJson(TRUE) . “});">Kirim”;
}

I added ACTION_POSTBACK but it didn’t work where should I correct it? thanks

ok thanks.
oh yes is it possible. the message notif is changed to an input form by filling in the reason. for example, when the approve is clicked out of the popup with only one input page after being filled, proceed to the update … if possible, does php maker already provide the event? if there can I be helped? if not yet on the server event can I apply this logic? Thank you very much…

hy I want to ask how to make an inpu text pop up.

function ListOptions_Load() {

	 $item = &$this->ListOptions->Add("send");
	 $item->Header = "Kirim"; // Set the column header (for List page)
	 $item->OnLeft = TRUE; // Link on left
	 $item->MoveTo(0);
}

function ListOptions_Rendered() {
$this->ListOptions->Items["send"]->Body = "<button><a href=\"#\" onclick=\"return ew.submitAction(event, {action: 'send', method: 'post', msg: 'Akan mengirim Kedivision Head?', key: " . $this->KeyToJson(TRUE) . "});\">Kirim</button></a>";}

	if ($action == "send") { // Check action name
			$rsnew = ["status" => "send","aktorsend" => "$username","senddate" => "$datetime"]; // Array of field(s) to be updated
			$result = $this->update($rsnew, "id = $row[id]"); // Update the current record only (the second argument is WHERE clause for UPDATE statement)
			if (!$result) { // Failure
					$this->setFailureMessage("Failed to Send, ID = " . $row["id"]);
					return FALSE; // Abort and rollback
			} elseif ($this->SelectedIndex == $this->SelectedCount) { // Last row
					$this->setSuccessMessage("Berhasil Send Ke Division Head.");                
			 }
			 return TRUE; // Success
		 }

how to change the popup text.
become the input form. Reason (input text and post updates in the table) can anyone help?

What did you mean by “how to change the popup text.”? Please explain it in more detail for more discussion.

just add the id on the button and make a popup input text reason after clicking ok save

newbiephp wrote:

onclick="return ew.submitAction(event, {action: ‘send’, method: ‘post’, msg: ‘Akan mengirim Kedivision Head?’, key: " . $this->KeyToJson(TRUE) . "});"

In your code you have written your own prompt message (the “msg” marked with *** above).

is there any reference to create your own promp? do you just have to call php maker? Thank you for the help

newbiephp wrote:

is there any reference to create your own promp?

Then do not set the “msg” and write our code to create your own prompt before calling ew.submitAction(). If you use Window.prompt(), see https://developer.mozilla.org/en-US/docs/Web/API/Window/prompt.

$this->ListOptions->Items[“reject”]->Body = "<a href="#" onclick="return window.prompt(‘Alasan Reject’),ew.submitAction(event, {action: ‘reject’, method: ‘post’, msg: ‘Yakin Akan Reject?’, key: " . $this->KeyToJson(TRUE) . “});">Reject”;

but I need that post reason to the table … what events and what additional syntax should I add? thanks

  • You did not remove msg so you’ll see 2 prompts
  • window.prompt() will return the user input
  • To sent data you may use “data” property, according to source code:
  • @param {Object} args.data - Object of user data that is sent to the server
    e.g. ew.submitAction(event, {action: ‘reject’, method: ‘post’, data: { reason: ‘some reason’ }, …})
    Then in the Row_CustomAction on the server side you may get back the reason by $_POST[“reason”] and write your code to handle it.

Hi newbiephp,

have you sorted out the issue with the entering text?
If yes could you please post your code?
I am looking for for a similar way of solution.

mpol_ch

@mpol_ch,You may just follow what arbei suggested above.