Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » ArrayCtrl, HeaderCtrl & GridCtrl » GridCtrl: How to respond to moving a row?
GridCtrl: How to respond to moving a row? [message #21806] Fri, 05 June 2009 18:32 Go to next message
jeremy_c is currently offline  jeremy_c
Messages: 175
Registered: August 2007
Location: Ohio, USA
Experienced Member
In my GridCtrl defining the questions, I have a field INT_ (POSITION) SQLDEFAULT(0) field that I currently do not populate. However, I would like to use the Append/Insert methods in conjunction with the Move Up/Down functions of the GridCtrl. My only problem is I cannot seem to figure out how to get notification that an item has moved up or down, thus I cannot update my POSITION values accordingly.

Any tips?

Thanks,

Jeremy
Re: GridCtrl: How to respond to moving a row? [message #21813 is a reply to message #21806] Sat, 06 June 2009 02:44 Go to previous messageGo to next message
jeremy_c is currently offline  jeremy_c
Messages: 175
Registered: August 2007
Location: Ohio, USA
Experienced Member
I made a very tiny patch and added in WhenMoveRow. It would be nice to have something a bit more powerfull such as WhenSwapRow and have it pass the row indexes that were swapped. Also something along the lines of CancelMove, i.e. like CancelInsert, CancelUpdate.

Anyway, with this I am progressing with my app and can rework it later if I totally missed how to accomplish this w/o changing GridCtrl.

Index: GridCtrl/GridCtrl.cpp
===================================================================
--- GridCtrl/GridCtrl.cpp       (revision 1276)
+++ GridCtrl/GridCtrl.cpp       (working copy)
@@ -5178,6 +5178,7 @@

        row_order = true;
        SetModify();
+       WhenMoveRow();

        return true;
 }
@@ -5231,6 +5232,9 @@
        }
        row_order = true;
        SetModify();
+
+       WhenMoveRow();
+
        return true;
 }

Index: GridCtrl/GridCtrl.h
===================================================================
--- GridCtrl/GridCtrl.h (revision 1276)
+++ GridCtrl/GridCtrl.h (working copy)
@@ -1692,6 +1692,7 @@
                Callback WhenRemoveRow;
                Callback WhenRemovedRow;
                Callback WhenDuplicateRow;
+               Callback WhenMoveRow;

                Callback WhenCancelNewRow;


Jeremy
Re: GridCtrl: How to respond to moving a row? [message #21911 is a reply to message #21813] Wed, 10 June 2009 15:17 Go to previous messageGo to next message
jeremy_c is currently offline  jeremy_c
Messages: 175
Registered: August 2007
Location: Ohio, USA
Experienced Member
Any thoughts on this? This app is progressing and I am relying pretty heavily on the ability to use the WhenMove event, however, that's my own local change to the U++ libraries which I don't want to maintain on each svn up if it's not the proper way of doing things or if something similar is not going to be supported officially.

Jeremy
Re: GridCtrl: How to respond to moving a row? [message #21924 is a reply to message #21911] Wed, 10 June 2009 23:10 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

jeremy_c wrote on Wed, 10 June 2009 09:17

Any thoughts on this? This app is progressing and I am relying pretty heavily on the ability to use the WhenMove event, however, that's my own local change to the U++ libraries which I don't want to maintain on each svn up if it's not the proper way of doing things or if something similar is not going to be supported officially.

Jeremy


Sorry for not responding. I've been busy with buying my new car Wink
Yes, the idea is good. I'll provide your patch after short review.
Re: GridCtrl: How to respond to moving a row? [message #21926 is a reply to message #21924] Thu, 11 June 2009 01:50 Go to previous messageGo to next message
jeremy_c is currently offline  jeremy_c
Messages: 175
Registered: August 2007
Location: Ohio, USA
Experienced Member
Great, however... Before you apply it, I think it needs some help. I am willing to work with it some more if you think it's worth while, however, this is my first venture into the U++ libs and it may take some time for me to figure out when you could whip it up in 10 minutes.

Right now, it simply calls a callback letting you know that something moved. It does not report what moved where. I was thinking it would be better to be able to let the callback know that row 1 was inserted after row 5. The problem right now is that say you have a db that contains ID, NAME, POSITION. Pretty easy. Well, when you get a "WhenMove" callback, you have to:

try
{
    for (int i=0; i < questions.GetCount(); i++)
    {
        SQL & ::Update(HIVE_ACC_Q)
            (POSITION, Value(i))
            .Where(ID == questions.Get(i, 0));
    }
}
catch (SqlExc &exc)
{
    Exclamation("[* " + DeQtfLf(exc) + "]");
}


If, however, we would send row 1 moved to row 5, that function could update rows only 1 - 5, instead of possibly 1 - 10,000 (maybe a bit extreme).

Further, it would be nice to have:

catch (SqlExc &exc)
{
    questions.CancelMove();
    // .....
}


as we have CancelInsert, CancelUpdate, etc...

BTW... Cool on the new car! I got a new car, but it's a minivan as my family has grown now to 4 daughters Smile

Jeremy
Re: GridCtrl: How to respond to moving a row? [message #21964 is a reply to message #21926] Fri, 12 June 2009 22:10 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

jeremy_c wrote on Wed, 10 June 2009 19:50

Great, however... Before you apply it, I think it needs some help. I am willing to work with it some more if you think it's worth while, however, this is my first venture into the U++ libs and it may take some time for me to figure out when you could whip it up in 10 minutes.
....


I've added WhenMoveRow(int n, int m) where n is source row and m destination row. You can also call CancelMove to cancel row moving. This is also valid for swap up/down operations. You must however keep in mind that WhenMoveRow is called before any real operation on grid (this is true for moving bunch of rows as well (WhenMoveRow is called for every moved row)). That's why CancelMove is possible. I haven't tested the code. Please write in case of any problem or bug.
Quote:


BTW... Cool on the new car! I got a new car, but it's a minivan as my family has grown now to 4 daughters Smile


Congratulations on your 4'th daugter Smile I bought Opel Astra combi. It's a nice car - enough for average family (I have one 3 years old daughter, but I'm gonna have the next one Wink).
[/quote]
Re: GridCtrl: How to respond to moving a row? [message #21965 is a reply to message #21964] Fri, 12 June 2009 22:16 Go to previous messageGo to next message
jeremy_c is currently offline  jeremy_c
Messages: 175
Registered: August 2007
Location: Ohio, USA
Experienced Member
Ha! I was just finishing up code to do exactly what you did, even the n, m var names... I'll do a svn up in a bit and let you know how it works out.

Thanks,

Jeremy
Re: GridCtrl: How to respond to moving a row? [message #22012 is a reply to message #21964] Sun, 14 June 2009 21:47 Go to previous message
jeremy_c is currently offline  jeremy_c
Messages: 175
Registered: August 2007
Location: Ohio, USA
Experienced Member
So far this is working, I'm going to do a bit more testing thought just to make sure Smile

Jeremy
Previous Topic: GridCtrl Search/Move Columns Bug
Next Topic: Grid Search Color on XP = very hard to read
Goto Forum:
  


Current Time: Fri Mar 29 06:40:28 CET 2024

Total time taken to generate the page: 0.01266 seconds