Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Report Control
  New Posts New Posts RSS Feed - Moving Report Rows
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Moving Report Rows

 Post Reply Post Reply
Author
Message
SteveStraley View Drop Down
Groupie
Groupie


Joined: 25 November 2005
Status: Offline
Points: 46
Post Options Post Options   Thanks (0) Thanks(0)   Quote SteveStraley Quote  Post ReplyReply Direct Link To This Post Topic: Moving Report Rows
    Posted: 04 October 2010 at 8:35pm
Hi,

A real quick question.   Let's say I have a report with 4 rows in it.   And let's say I want to move row 3 up to row 2.   How?

Thanks,

Steve - In Confusionland...Confused
Back to Top
SHAN View Drop Down
Groupie
Groupie
Avatar

Joined: 17 July 2010
Location: Dubai
Status: Offline
Points: 73
Post Options Post Options   Thanks (0) Thanks(0)   Quote SHAN Quote  Post ReplyReply Direct Link To This Post Posted: 05 October 2010 at 12:34am
Hi Steve,
 
Just add this code and drag and drop the rows to any location ....!
 
Dim MovRow As Long
        Movrow = ReportControl1.EnableDragDrop("DragDrop", xtpReportAllowDrag + xtpReportAllowDrop)
 
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows 7 Professional
Language: Visual Basic 6.0
Back to Top
SteveStraley View Drop Down
Groupie
Groupie


Joined: 25 November 2005
Status: Offline
Points: 46
Post Options Post Options   Thanks (0) Thanks(0)   Quote SteveStraley Quote  Post ReplyReply Direct Link To This Post Posted: 05 October 2010 at 9:55am
Shan,
 
Thanks... but I'm wanting to do it programatically.   In other words, say I have 10 rows.   I want to change the order in the display where ROW 5 moves up to ROW 4 and ROW 4 moves down to ROW 5.
 
I'm trying all sorts of stuff but nothing is working or that is jumping out at me as the obvious...
 
Steve
Back to Top
Aaron View Drop Down
Senior Member
Senior Member
Avatar

Joined: 29 January 2008
Status: Offline
Points: 2192
Post Options Post Options   Thanks (0) Thanks(0)   Quote Aaron Quote  Post ReplyReply Direct Link To This Post Posted: 05 October 2010 at 2:42pm
Hi Steve,
 
Look at SortPriority and GroupPriority property in help file and maybe useable for your option...
 
  
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0

Zero replies is not an option....
Back to Top
Aaron View Drop Down
Senior Member
Senior Member
Avatar

Joined: 29 January 2008
Status: Offline
Points: 2192
Post Options Post Options   Thanks (0) Thanks(0)   Quote Aaron Quote  Post ReplyReply Direct Link To This Post Posted: 05 October 2010 at 2:50pm
Originally posted by SteveStraley SteveStraley wrote:

Shan,
 
Thanks... but I'm wanting to do it programatically.   In other words, say I have 10 rows.   I want to change the order in the display where ROW 5 moves up to ROW 4 and ROW 4 moves down to ROW 5.
 
I'm trying all sorts of stuff but nothing is working or that is jumping out at me as the obvious...
 
Steve
 
Hi again,
 
How are you going to "move" the rows? Do you have buttons to change the order or what?
Let me know and I think you are able to change order with the properties I mentioned...
It would help if you have a test project Wink
 
Thanks
 
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0

Zero replies is not an option....
Back to Top
SteveStraley View Drop Down
Groupie
Groupie


Joined: 25 November 2005
Status: Offline
Points: 46
Post Options Post Options   Thanks (0) Thanks(0)   Quote SteveStraley Quote  Post ReplyReply Direct Link To This Post Posted: 05 October 2010 at 3:07pm
I have a test window that I'm using to test this. 
 
How am I moving the rows?   If the user right-mouse clicks on a row, a menu to MOVE UP or MOVE DOWN the row appears.   If the user select MOVE UP, I simply want to move (e.g.) ROW 5 up to 4 and then ROW 4 to move down to ROW 5.    For example:
 
1
2
3
4 <-- User Clicks here
5
 
Becomes
 
1
2
4
3
5
 
Steve
 
Back to Top
SteveStraley View Drop Down
Groupie
Groupie


Joined: 25 November 2005
Status: Offline
Points: 46
Post Options Post Options   Thanks (0) Thanks(0)   Quote SteveStraley Quote  Post ReplyReply Direct Link To This Post Posted: 05 October 2010 at 10:50pm
Ok... I figured out a solution to the question that works but I have to say... it's kludgy.   If only the Row property of the report could have an insert or if the values within the collection could be manipulated life would be easier.

Here's what I did to solve.   I created another REPORT control on my form and made it invisible, not enabled, and not tab stopped.   In essence, it is a "holding" container.   I added column structures to this that matched the column structure of the report that I want to move the rows up and down in.

Then in the event methods to the context menu clicks, I added 3 methods:


    protected void ClearHoldingReport(int nSelect)
    {
      this.oRightGrid.RemoveAllRows();
      for (int i = 0; i < this.oHoldingReport.Rows.Count; i++)
      {
        this.oRightGridData.AddRecordEx(this.oHoldingReport.Rows.Record);
      }
      while (this.oHoldingReport.Rows.Count != 0)
      {
        this.oHoldingReport.RemoveRowEx(this.oHoldingReport.Rows[0]);
      }
      this.oRightGridData.Rows[nSelect].Selected = true;

    }

    protected void moveRightDataUp(object sender, EventArgs e)
    {
      if (this.oRightGridData.SelectedRows.Count == 1)
      {
        int nStartingAt = this.oRightGridData.SelectedRows[0].Index;
        int nUpTo = nStartingAt - 1;

        if (nStartingAt != 0)
        {
          for (int i = 0; i < nUpTo; i++)
          {
            this.oHoldingReport.AddRecordEx(this.oRightGridData.Rows.Record);
          }

          this.oHoldingReport.AddRecordEx(this.oRightGridData.Rows[nStartingAt].Record);

          this.oHoldingReport.AddRecordEx(this.oRightGridData.Rows[nUpTo].Record);

          for (int i = nStartingAt + 1; i < this.oRightGridData.Rows.Count; i++)
          {
            this.oHoldingReport.AddRecordEx(this.oRightGridData.Rows.Record);
          }

          this.ClearHoldingReport(nUpTo);

        }
      }
    }
    protected void moveRightDataDown(object sender, EventArgs e)
    {
      if (this.oRightGridData.SelectedRows.Count == 1)
      {
        int nStartingAt = this.oRightGridData.SelectedRows[0].Index;
        int nDownTo = nStartingAt + 1;

        if (nStartingAt != this.oRightGridData.Rows.Count - 1)
        {
          for (int i = 0; i < nStartingAt; i++)
          {
            this.oHoldingReport.AddRecordEx(this.oRightGridData.Rows.Record);
          }

          this.oHoldingReport.AddRecordEx(this.oRightGridData.Rows[nDownTo].Record);

          this.oHoldingReport.AddRecordEx(this.oRightGridData.Rows[nStartingAt].Record);

          for (int i = nDownTo + 1; i < this.oRightGridData.Rows.Count; i++)
          {
            this.oHoldingReport.AddRecordEx(this.oRightGridData.Rows.Record);
          }

          this.ClearHoldingReport(nDownTo);

        }
      }
    }

Like I said, it works but moving rows to the holding report container with the new order then moving them back while appears fast just is uncomfortable.

If there are any better ways, I'm all ears...

Steve
Back to Top
Aaron View Drop Down
Senior Member
Senior Member
Avatar

Joined: 29 January 2008
Status: Offline
Points: 2192
Post Options Post Options   Thanks (0) Thanks(0)   Quote Aaron Quote  Post ReplyReply Direct Link To This Post Posted: 06 October 2010 at 4:40am
Hi Steve,
 
Well, now I know you are using VB.NET Wink
 
I tried to get your problem working with VB6.0 (isn't that different from VB.NET) so the only thing we have to do is "copy" record and "move" it to another position... Should be simple, right?
 
I thought InsertAt method would work for me, checking the help file, yes... that should work.
 
 
InsertAt method in help:

Remarks

InsertAt will move an existing ReportRecord to the specified index.  To create a new record at a specific index use the Insert method.

This method MOVES a record to specific location, YES !!!   Just few lines of code in MoveUp and one in MoveDown...
 
Private Sub mnuMoveUp_Click()
With Me.wndReportControl
        If .FocusedRow.Index > 0 Then
            .Records.InsertAt .FocusedRow.Index - 1, .FocusedRow.Record
            .Populate
        End If
    End With
End Sub
 
Run the demo... grrrr... record isn't "moved" but copied on specific location. Either helpfile is wrong or this is bug... it's up to you CJ Wink
 
Let us assume helpfile isn't OK. Removing the record that wasn't removed by InsertAt method can be removed with RemoveAt method, right?
 
Private Sub mnuMoveUp_Click()
    'If column is sorted you get weird behaviour !!!
    'Me.wndReportControl.SortOrder.DeleteAll

   
    With Me.wndReportControl
        If .FocusedRow.Index > 0 Then
            .Records.RemoveAt .FocusedRow.Index
            .Records.InsertAt .FocusedRow.Index - 1, .FocusedRow.Record
            .Populate
            .Redraw 'Don't know why but I have to call Redraw twice in order
            .Redraw 'to update captions in second column
        End If
    End With
End Sub
 
Run demo again... OK, now we are talking. It is working...
 
So far so good, but what about sorted column? Ok let us click on columnheader... grrrr... it doesn't work anymore and I don't see any difference without a sortorder applied. Maybe someone else can give it a try???
 
Here's demo to try with uploads/3701/TestMovingRecord.zip
 
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0

Zero replies is not an option....
Back to Top
SteveStraley View Drop Down
Groupie
Groupie


Joined: 25 November 2005
Status: Offline
Points: 46
Post Options Post Options   Thanks (0) Thanks(0)   Quote SteveStraley Quote  Post ReplyReply Direct Link To This Post Posted: 06 October 2010 at 10:20am
Aaron,
 
Thanks for the reply.   NO, I'm not using VB.NET... you should look again...Wink
 
Thanks for the demo but I got the code to work, columns and all.   As far as your comment about documentation, let me say this up front.   As a book author of over 20 books, if a piece of software cannot be used either because the code is bad or the documentation is bad... then it's a bug - who's responsibility it is to fix is a different matter.   I've always been disappointed with CJ documentation and examples; the reason I stay is what I get for the price so I guess I'm getting what I paid for (one could argue).   FWIW, I've offered to help write white papers in the past but never felt this was embraced - as a matter of fact conversations of this kind were quickly met with who has legal copyright, who retains control, and fud like that.   This is why I never pursued it and won't.   Too many other battles to fight than this one.
 
Again, thanks for the reply and your code - maybe someone else can benefit from BOTH of our examples.
 
Steve
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.141 seconds.