The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
|
|
Editable Datagrid question
Posted: 14 Nov 07 11:10 AM
|
I have an editable grid on a popup screen. Obviously if a user changes some data in the editable grid, then pushes cancel on the popup screen the data edited in the grid is saved anyway. Is there a way to cancel the changes made in editable datagrid when the user clicks cancel on the popup screen? The first thing I come up with is to track any changes made and back them off with SQL if the user presses cancel. This then opens a whole can of worms capturing what is saved as I have had terrible luck with events firing consistantly when data is changed in the grid..
Has anyone come across this or have any suggestions? Thanks |
|
|
|
Re: Editable Datagrid question
Posted: 15 Nov 07 12:13 AM
|
You need to disconnect your datagrid from the underlying data. Then (when user clicks OK/Cancel) update or cancel the changes to the datagrid's recorsdset as required - this is how Opportunity Products works, so suggest you use something similar (but I'll bet you'll end up with something 50 times less complex).
PP |
|
|
|
Re: Editable Datagrid question
Posted: 15 Nov 07 9:56 AM
|
Yes, in these situations, I use disconnected datagrids as well, and I even build those datagrids at runtime. I tried using a connected datagrid and track the changes, but it kept causing problems and unexpected data issues. There is a bit more code involved, but once you have it all set up on your first form, you can reuse the pattern for future work. It's very very nice to work with once it's all set up. |
|
|
|
Re: Editable Datagrid question
Posted: 16 Nov 07 9:15 AM
|
Connected Data Grids SLX fires off AUTOMAGICALLY the Update SQL statement for that specific field if there is a change to the oldvalue to the new value..... so no way to cancel it....you have to go with a disconnected grid.....see the Opportunity Product 'stuff' for hints on this (the whole subsystem is disconnected and build from scratch....this takes a LOT of time to code).
The syntax of the Update call in 7.2.x is UPDATE TABLENAME SET ChangedFieldName = NewValue WHERE TablenameID = '" & KeyRowValue & "' AND ChangedFieldName = OldValue
That last AND clause is NEW, it's a gothca, and it helps with Optimistic Locking in a massively concurrent use database.....
If you have other fields that you want to change you must use a SQL statement.....and then you CAN NOT change the Edited Field through that SQL Update statement (because the AUTOMAGIC SQL Update Statement is looking for the OLD VALUE of that field.....and will throw an error if it doesn't find it!!!!!!).
So! Change Price from $5 to $10 inline Grid Edit SalesLogix AUTOMAGICALLY issues: UPDATE OPPORTUNITY_PRODUCT SET PRICE = 10 WHERE OPPPRODUCTID = '" & KeyRowValue & "' AND PRICE = 5
You need to get the Quantity......and new price in the Edited event for the grid.... Then Amount = Price * Quantity UPDATE OPPORTUNITY_PRODUCT SET Amount = 30 WHERE OPPPRODUCTID = '" & KeyRowValue & "'
Note that I didn't change the Price in my Update statement......
Make Sense? |
|
|
| |
| |
|