Hello,
I'm having an issue that's related to my Dynamically loaded userctrls within a dock, but it was different enough to warrant a new thread.
It would greatly simplify things if there were a server event that would fire for the specific dock control that was moved that would have an e.NewIndex and e.OldIndex parameter values. This gives you a much finer degree of control when creating your own state bag for the dock control.
Here's the issue with NOT having that event available. For the example, I have a table like so:
tblPageContent
- PageNumber
- ObjectID (note: object id can only exist on one page, so its a unique value within this table)
- ObjectOrder
Say I have 8 docks dynamically loaded and I move one up 4 places in the layout. When I move a dock up, the following happens;
- 1. OnInit is triggered and the dynamic docks are 'refreshed'
- 2. 'Refreshing' and save process include:
>Adding docks in Init (wired-up to DockPositionedChanged)
>DockLoadLayout being triggered
>DockPositionChanged event firing for each affected dock
>> In this event a page scoped StringBuilder variable is built
and loaded with each ObjectID(Dock ID) and Index affected
in this event
>DockSaveLayout is triggered
>> If the Page level scoped StringBuilder variable is NOT nothing
(which is only filled in the DockPositionChanged event), then
the deliminated string of objectID's and it's new indexes
are updated in the database table.
Notes about the above:
1. The above forces me to pass in a deliminated string of ALL affected objects wrapped in the docks AND their new indexes. So since there's no easy way of handling arrays for both SQL Server and Oracle, that means passing in a string like so to be parsed by the Stored Procedure:
"|objectid,index|objectid,index|" OR "|72,2||73,3||74,1|".
2. I then have a messy Oracle update statement where the objectid is parsed out of the string in the where clause and the index value is parsed out (the messy part) in the SET statement:
update tblPageContent set
object_order = SUBSTR(PageObjects_in,INSTR(PageObjects_in,'|'||TRIM(objectid)||',')+LENGTH(TRIM(objectid))+2,(INSTR(PageObjects_in,'|',INSTR(PageObjects_in,'|'||TRIM(objectid)||',')+1))-(INSTR(PageObjects_in,'|'||TRIM(objectid)||',')+LENGTH(TRIM(objectid))+2))
where INSTR(PageObjects_in,'|'||TRIM(objectid)||',') > 0;
NOTE: The SQL Server version uses CharIndexes in place of INSTR, etc.
That would be all fine and well assuming I didn't then need to write some code to handle the specific object that was moved. I have no real way of identifying the dock/object that was moved?? I only have a RANGE of affected docks/objects.
A problem that could crop up with the above object order update method is if the string get's longer than 4000 characters, I can no longer pass this into Oracle as it exceeds the Varchar2 limit (SQL Servers is 8000). This could occur if I had a long list or even a medium list with very high objectID's that would quickly eat up that 4000 character limit if I were to move an item from the bottom towards the top (as everything in between has to be updated via the DockPositionChanged method).
If I had actually done as a previous thread suggested (in the "Dynamic Dock UserCtrl Wrappers" thread) and forgone the DockPositionChanged method (to build my stringbuilder list of objects to update) and just used the SaveDockLayout method, then I would've had to build a deliminated string for EVERY single dock in that list and needlessly updated those object orders in the database (which also puts needlessly more row locks in the database table while updating).
So it's nice to have this DockPositionChanged event around, but in addition to it, could something like a 'DockPositionChanging' event be added with a parameter that has e.OldIndex and e.NewIndex. Then I can identify the specific object/dock that needs to be adjusted in the database. I can also simplify my update statements and have only 4 integer stored proc parameters (pagenumber, objectid, oldindex, newindex). It's not too hard to then write a SQL statement that would increment or decrement by 1 the 'objectorder' field for any objects 'below' or 'above' the current object.
In short - does a dock server event already exist that let's me identify the specific dock that was moved/is moving and if not, could an event be added? Again, my specific issue is that I can't identify the specific dock id (equal to objectID in my example) that was moved.
Thanks,
Chris