Darren Hall
|
Posted: 02/06/2004, 8:08 AM |
|
Currently the editable grid is not intelligent in that if you make a change to only one row, the entire grid is updated. It does not seem obvious that is happening in most cases, but I assure you it is!
If you put an update trigger on a table so that it prints a list of primary keys of all updated rows and then create an editable grid on that table, changing one row via the grid will result in all rows primary keys being printed.
This proves a problem if for instance you have a field that is used to indicate the row was updated.
It would be much better if CCS could check which fields had changed and only update that specific row.
Darren
|
|
|
peterr
Posts: 5971
|
Posted: 02/06/2004, 2:20 PM |
|
I just like to confirm that you are correct regarding the current implementation of the Editable Grid. It was designed to update all records.
However, I believe that the current Grid functionality can be extended to cover such functionality.
For example I think that you can currently add a hidden field to your Grid, plus write some OnChange JavaScript code that will trigger this hidden field when something is changed. Then you could use Where Parameters to update only those records that have changed, for example by checking that hidden_field = True.
(I haven't tested this but logically should work)
Your Wish will be added to our to-do-list though, as this is something that could be improved on our end. At the least we may create an example of how to do this with the current version of the Grid.
Another question though may be how to resolve situations where several people update the same records at the same time. Whose changes should overwrite whose? There are some solutions that can be implemented to handle this already - I'm just brining this as an additional ways of working with Editable Grids. While there may be more questions and possibilities.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
|
|
marcwolf
Posts: 361
|
Posted: 02/08/2004, 9:16 PM |
|
Actually - I had to do something very similar recently
I use ASP so my example will be for that.
Lets look at the BeforeExecuteUpdate on the Grid
Each row in the grid will call this routine.
The values of the row have been transferred back into the grid control so you can access them.
The Grid instance of clsCommand has been passed into the routine it can be accessed.
The SQL statement is built and then the SQL is passed to clsCommand - which updates the DB
Now - a property within clsCommand CommandOperation and this tells clsCommand what to do, but setting this to a dummy value will stop the SQL from being executed, and therefore doing what you need.
Function Grid_BeforeExecuteUpdate
If Grid1.Hidden1.value ="0" then
Grid1.Command.CommandOperation=99 ' no update
else
' do nothing - let update process normally
end if
End Function
Only drawback with this is that you cannot use the Error's collection and will need to set up your own method using a session variable and a display if not empty.
Have fun
_________________
' Coding Coding Coding
Keep Those Keyboards Coding.
Raw Code!!!!!!!
|
|
|
LV
|
Posted: 05/19/2004, 11:08 AM |
|
I have editable grid which contains required fields for new entry, if I edit one or two rows click on Submit I get the error message for the new row . It would be nice for CCS only flag the rows that I have changed values and only update those rather than the entire grid.
|
|
|
|