sneakers
Posts: 13
|
Posted: 04/29/2004, 9:30 AM |
|
When selecting a record to modify, I want to disable the Delete button if the record is used in another table.
I have added the following code in the BeforeShow event of the form. The DeleteAllowed is set to false but it still displays on the web page. Any help would be appreciated.
if ($interview->EditMode) {
$new_db = new clsDBpe_database;
$found_flag = CCDLookUp("process_desc", "tbl_pe_process",
"start_interview_id=" . CCGetParam("interview_id"), $new_db);
unset($new_db);
if ($found_flag != "") {
$interview->DeleteAllowed = false;
}
}
|
|
|
peterr
Posts: 5971
|
Posted: 04/29/2004, 9:23 PM |
|
The above code may not work unless you also set the “Restricted” property of your form to “Yes”. That’s because CodeCharge Studio generates the code appropriate for hiding and disabling buttons only when there is a need to do so, and restricting page access indicates that certain users are not allowed to add, update or delete records.
Otherwise you could also try placing this code in the page's After Initialize event.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
|
|
sneakers
Posts: 13
|
Posted: 04/30/2004, 5:56 AM |
|
Thanks for your response.
I did come up with a solution that I'd like to share.
I am using an editable grid with new rows added automatically and added the code according to the CCS example.
In addition, I added an attribute to the table row called "disablechkbox". I then modified the php code to include what I need for disabling the checkbox. I want the checkbox disable if the record is used in another table.
Here's the code for anyone who needs to disable the checkbox based on other criteria.
In the HTML, you need to:
1. Add the attribute 'disableckbox=""' then add a label named "DisableChkBox"
2. Add "{DisableChkBox}" in the checkbox input tag.
<tr id="{RowIDAttribute}" name="{RowNameAttribute}" {RowStyleAttribute} addedrow="{AddedRow}" disablechkbox="{DisableChkBox}">
<input class="FacetInput" type="checkbox" value="1" name="{CheckBox_Delete_Name}" {CheckBox_Delete} {DisableChkBox}>
In the Before Show Row event, I added code for disabling the checkbox.
Below is the code for doing a new row and I bolded what I added.
global $RowNumber,$FirstEmptyRow;
$RowNumber++;
$interview_options->RowIDAttribute->SetValue($RowNumber);
$interview_options->AddedRow->SetValue("false");
// DisableChkBox is for disabling checkbox if option used in interview
$interview_options->DisableChkBox->SetValue("");
//
if (($RowNumber <= $interview_options->PageSize) && ($RowNumber <= $interview_options->ds->RecordsCount)) {
$interview_options->RowNameAttribute->SetValue("FillRow");
// START - Determine if option is used in the interview.
$new_db = new clsDBpe_database;
$rec_cnt = CCDLookUp("COUNT(*)", "tbl_pe_interview_path",
"path_opt_id=" .
$new_db->ToSQL($interview_options->opt_id->GetValue(), ccsInteger), $new_db);
if ($rec_cnt > 0) {
$interview_options->DisableChkBox->SetValue("disabled");
}
unset($new_db);
// END - option used in interview
} else {
$interview_options->RowNameAttribute->SetValue("EmptyRow");
$interview_options->RowStyleAttribute->SetValue("style=\"display:none;\"");
$interview_options->AddedRow->SetValue("true");
if (!$FirstEmptyRow) {
$interview_options->RowStyleAttribute->SetValue("");
$FirstEmptyRow = true;
}
if (isset($interview_options->RowsErrors[$RowNumber])) {
$interview_options->RowStyleAttribute->SetValue("");
}
}
|
|
|
|