I’m using v 17.0.4. I have a linked table (actually is a view) that has 2 new columns added in ListOptions_Load(). Each of this new columns are used to add a custom action defined instanced in ListOptions_Rendered() and defined in Row_CustomAction(). One column is to approve and the other to reject some requests. Internally the custom action is an UPDATE to a flag in the original table (because can’t update the linked view).
In ListOptions_Rendered() I wrote this:
//Approve
$this->ListOptions->Items[“approve_req”]->Body =
"<a href="#" onclick="return ew_SubmitAction(event, {action: ‘approve_req’, method: ‘ajax’, msg: ’ Approve request?‘, key: " . $this->KeyToJson() . “});">
<span class="glyphicon glyphicon-thumbs-up ewIcon" >
”;
//Reject
$this->ListOptions->Items[“reject_req”]->Body =
"<a href="#" onclick="return ew_SubmitAction(event, {action: ‘reject_req’, method: ‘ajax’, msg: ’ Reject request?’, key: " . $this->KeyToJson() . “});">
<span class="glyphicon glyphicon-thumbs-down ewIcon" >
”;In Row_CustomAction() I wrote this:
if ($action == “approve_req”) {
ew_Execute(“UPDATE requests SET approval_flag= ‘1’ WHERE id =”.$row[“id”]);
$this->setSuccessMessage(“Request approved: “.$row[“request_id”].”.”);
return TRUE;
} elseif ($action == “reject_req”) {
ew_Execute(“UPDATE requests SET approval_flag = ‘-1’ WHERE id =”.$row[“id”]);
$this->setSuccessMessage(“Request rejected “.$row[“request_id”].”.”);
return TRUE;
} else {
return TRUE;
}
Comment: List page has a filter to show only request with flag = 0.It works fine (it executs the UPDATEs correctly), but I’m not sure if on my first tests, after do the custom action (approve or reject a request), the page (list page) refreshes itself, so after approve or reject the request the page continue showing only request with flag=0 but now it doesn’t. Anyway I’d like to do this, how could I do it: refresh the page after clic on aceppt modal button that confirms the change?
You can pass the callback function to the ew_SubmitAction and perform reload in your callback function.For example:
(In ListOptions_Loaded Server Event)
$this->ListOptions->Items[“new”]->Body = "<a href="#" onclick="return ew_SubmitAction(event, {action: ‘star’, method: ‘ajax’, msg: ‘Add star?’, key: " . $this->KeyToJson() . “, success: myfunction});">Add Star”;(In Client Scripts)
function myfunction(){
location.reload();
}
In Row_CustomAction server event, you may insert the following code to check whether all the selected row(s) has(have) already processed.Modify this part:
// redirect page to masteredit
$getlastid = ExecuteScalar("SELECT id FROM mytable WHERE cd = '".$row["cd"]."' ORDER BY id DESC LIMIT 1");
header('location: t_masterdetailedit.php?showdetail=t_detail&detailid='.$getlastid);
to:
if ($this->SelectedIndex == $this->SelectedCount) { // Last row
// redirect page to masteredit
$getlastid = ExecuteScalar("SELECT id FROM mytable WHERE cd = '".$row["cd"]."' ORDER BY id DESC LIMIT 1");
header('location: t_masterdetailedit.php?showdetail=t_detail&detailid='.$getlastid);
}
Its not work…
it generates a pop up display and show code :MY NAME APP Object.assign(ew, { LANGUAGE_ID: “id”, DATE_SEPARATOR: “/”, // Date separator TIME_SEPARATOR: “.”, // Time separator DATE_FORMAT: “dd/mm/yyyy”, // Default date format DATE_FORMAT_ID: 7, // Default date format ID DATETIME_WITHOUT_SECONDS: false, // Date/Time without seconds DECIMAL_POINT: “,”, THOUSANDS_SEP: “.”, GENERATE_PASSWORD_LENGTH: 16, SESSION_TIMEOUT: 0, // Session timeout time (seconds) SESSION_TIMEOUT_COUNTDOWN: 60, // Count down time to session timeout (seconds) SESSION_KEEP_ALIVE_INTERVAL: 0, // Keep alive interval (seconds) RELATIVE_PATH: “”, // Relative path IS_LOGGEDIN: true, // Is logged in IS_SYS_ADMIN: false, // Is sys admin CURRENT_USER_NAME: “admin”, // Current user name IS_AUTOLOGIN: false, // Is logged in with option “Auto login until I logout explicitly” TIMEOUT_URL: “logout.php”, // Timeout URL // PHP TOKEN_NAME: “token”, // Token name API_FILE_TOKEN_NAME: “filetoken”, // API file token name API_URL: “api/index.php”, // API file name // PHP API_ACTION_NAME: “action”, // API action name API_OBJECT_NAME: “object”, // API object name API_FIELD_NAME: “field”, // API field name API_KEY_NAME: “key”, // API key name API_LIST_ACTION: “list”, // API list action API_VIEW_ACTION: “view”, // API view action API_ADD_ACTION: “add”, // API add action API_EDIT_ACTION: “edit”, // API edit action API_DELETE_ACTION: “delete”, // API delete action API_LOGIN_ACTION: “login”, // API login action API_FILE_ACTION: “file”, // API file action API_UPLOAD_ACTION: “upload”, // API upload action …and so on