Moving Report Rows |
Post Reply |
Author | |
SteveStraley
Groupie Joined: 25 November 2005 Status: Offline Points: 46 |
Post Options
Thanks(0)
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... |
|
SHAN
Groupie Joined: 17 July 2010 Location: Dubai Status: Offline Points: 73 |
Post Options
Thanks(0)
|
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 |
|
SteveStraley
Groupie Joined: 25 November 2005 Status: Offline Points: 46 |
Post Options
Thanks(0)
|
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
|
|
Aaron
Senior Member Joined: 29 January 2008 Status: Offline Points: 2192 |
Post Options
Thanks(0)
|
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.... |
|
Aaron
Senior Member Joined: 29 January 2008 Status: Offline Points: 2192 |
Post Options
Thanks(0)
|
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
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.... |
|
SteveStraley
Groupie Joined: 25 November 2005 Status: Offline Points: 46 |
Post Options
Thanks(0)
|
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
|
|
SteveStraley
Groupie Joined: 25 November 2005 Status: Offline Points: 46 |
Post Options
Thanks(0)
|
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 |
|
Aaron
Senior Member Joined: 29 January 2008 Status: Offline Points: 2192 |
Post Options
Thanks(0)
|
Hi Steve,
Well, now I know you are using VB.NET
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:
RemarksInsertAt 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
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.... |
|
SteveStraley
Groupie Joined: 25 November 2005 Status: Offline Points: 46 |
Post Options
Thanks(0)
|
Aaron,
Thanks for the reply. NO, I'm not using VB.NET... you should look again...
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
|
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |