matt
|
| Posted: 07/11/2005, 5:56 PM |
|
I have a situation where I would like to have a single editable grid that contains both existing data as well as the ability to enter new rows to the database. The users can insert new rows and delete old rows, but can not modify the values of existing rows. Is there a way to construct an editable grid such that a user can not enter values for existing rows (i.e. they can just check the delete box), but still have an empty row at the bottom for entering new data? Disallowing modify on the grid prevents modified data from going to the db, but the user can still type data into the fields which makes for amateurish behavior of the UI.
|
|
|
 |
datadoit.com
|
| Posted: 07/11/2005, 7:33 PM |
|
You could disable the grid row controls by setting a template variable and
placing the value of that variable into the HTML. If there's a value for
the field, then disallow updating of that field.
BeforeShow for Control:
global $YourField;
global $Tpl;
if ($grid->YourField->GetValue()) {
$Tpl->SetVar("FieldUpdate", disabled);
}
else {
$Tpl->SetVar("FieldUpdate", "");
}
Then, in the HTML for the grid place the label:
<input value="{YourField}" name="{YourField_Name}" {FieldUpdate}>
This is the same as having:
<input value="{YourField}" name="{YourField_Name}" disabled>
but you're setting it dynamically based on a condition.
NOTE: If you're still going to allow the deletion of a grid row using a
checkbox_delete, next to each field control I'd put in a hidden control for
the same field. If you don't, and a field is "disabled" in the record
you're attempting to delete, then you may get errors when trying to delete
the record.
-MikeR
|
|
|
 |
|