Page 1 of 1
Disable a field with server event
Posted: Sat Sep 14, 2024 3:02 am
by mpol_ch
Hi,
I am trying to avoid the editing of field "Kostenstelle" with below code but it does not work.
The field is a lookup field with activated option "use modal dialog for lookup".
Any idea?
I am inserting the following code for Edit Page / Page Load
function Page_Load() {
// Check if it's an edit operation
if ($this->IsEdit) {
$this->Kostenstelle->ReadOnly = true;
}
}
mpol_ch
Re: Page_load: ReadOnly=true
Posted: Sat Sep 14, 2024 3:48 am
by sticcino
wrong event
**function Page_Render()**
{
$this->EmployeeId->ReadOnly = true;
$this->EmployeePassword->Visible = false;
}
Re: Page_Load - Set ReadOnly=true
Posted: Sat Sep 14, 2024 7:43 pm
by mpol_ch
I solved it with following code:
function Row_Rendered() {
// Get a field value of ks_gueltig from Kostenstelle
$currentKostenstelle = $this->Kostenstelle->CurrentValue;
if ($currentKostenstelle !== null && $currentKostenstelle !== '') {
$ks_gueltig = ExecuteScalar("SELECT ks_gueltig FROM kostenstelle WHERE ksid=".$this->Kostenstelle->CurrentValue );
if ($ks_gueltig == 0) {
$this->Kostenstelle->EditAttrs["disabled"] = "disabled";
}
}
}
mpol_ch