pkrawetz
Posts: 77
|
Posted: 06/08/2004, 10:37 AM |
|
ghtracy - You provided advice on changing the insertallowed to false when you have a prefilled field on an updatable grid. I tried this code in different spots but couldn't get it to work. Now new rows are ignored. I'm using PHP as the language. I need to know what event to place the code under
|
|
|
ghtracey
Posts: 23
|
Posted: 06/08/2004, 11:21 AM |
|
There are a couple of ways of doing this. The first is to do a test in the BeforeExecuteInsert event. If the prefilled field is the only field containing data, set the form->InsertAllowed = False. Depending on the number of fields in your form, this could require a fairly large check. Also, if you have required fields, most likely every time you try to change one record in the grid, the validation will throw errors regarding required fields not being filled, which requires you to unset the prefilled fields in the blank record during an update. As you can see, this is a bit of a hassle.
What I eventually did, was to modify the Insert Method for the form, and recode the portion that creates the insert. I leave the hidden form field blank and only fill it when an insert is actually being performed. This gets you around all the testing and having to use InsertAllowed.
For example, I have an editable grid in one application that allows you to enter items into a table that is keyed using a field boxID, which is used as the paramter for the boxes select. I need this field to exist in order to do an insert, but it is not to be changed by the user. Presetting the hidden field causes all the problems mentioned above, so in the Insert Method, I replaced
. $this->ToSQL($this->boxID>GetDBValue(), $this->boxID>DataType) . ", "
with
. $this->ToSQL(CCGetParam("box"), $this->boxID->DataType) . ","
Problem solved without any complicated checks. Give that a try.
_________________
Graham Tracey
Council of Yukon First Nations |
|
|
|