Using a DevExpress XtraGrid and Trying to Move Records Up or Down


Author
Message
Buffie
Buffie
StrataFrame User (271 reputation)StrataFrame User (271 reputation)StrataFrame User (271 reputation)StrataFrame User (271 reputation)StrataFrame User (271 reputation)StrataFrame User (271 reputation)StrataFrame User (271 reputation)StrataFrame User (271 reputation)StrataFrame User (271 reputation)
Group: StrataFrame Users
Posts: 119, Visits: 11K
With Edhy's help and expertise I (we) were able to get the move to work in the DevExpress Grid.  Edhy is such a valuable resource....

If someone is interested in the code I will gladly post it.
Edhy Rijo
E
StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Terry Bottorff (9/7/2014)

Also, the following line of code would not let me put BO1 on the end.

boInGridView = TryCast(Me.GridView1.GetRow(index), ResultsPerfsChecksTimedEventBO)

That is correct because when you Cast() or TryCast() you have to pass the class type as a parameter not an instance of a class which in this case would be the BO1, so my code is correct.
I know it can be confusing but if you look closely it is actually very simple. 

I have to go out now and will be back in 2 hours, if you want email me your phone and I will call you to make a remote session and see your project, this could get done in 10-20 minutes and would be easier to explain.

Edhy Rijo

Terry Bottorff
Terry Bottorff
Advanced StrataFrame User (676 reputation)Advanced StrataFrame User (676 reputation)Advanced StrataFrame User (676 reputation)Advanced StrataFrame User (676 reputation)Advanced StrataFrame User (676 reputation)Advanced StrataFrame User (676 reputation)Advanced StrataFrame User (676 reputation)Advanced StrataFrame User (676 reputation)Advanced StrataFrame User (676 reputation)
Group: Forum Members
Posts: 448, Visits: 12K
I did set the SortOrder so I had that piece but I am confused. After I create the new BO based on the record that has Focus what am I to do with it?
I see it does have the JudgesSheetPositionNumber value in boInGridView.JudgesSheetPositionNumber and certainly when I add 1 to that it will tell me the position it is going but I don't know what to do from there? 

Also, the following line of code would not let me put BO1 on the end.

boInGridView = TryCast(Me.GridView1.GetRow(index), ResultsPerfsChecksTimedEventBO)

Yes Edhy, I agree I was planning on validating the move when in first position and last position.

Buffie
Buffie
StrataFrame User (271 reputation)StrataFrame User (271 reputation)StrataFrame User (271 reputation)StrataFrame User (271 reputation)StrataFrame User (271 reputation)StrataFrame User (271 reputation)StrataFrame User (271 reputation)StrataFrame User (271 reputation)StrataFrame User (271 reputation)
Group: StrataFrame Users
Posts: 119, Visits: 11K
Well my code Does Not Work if you try to move the Same Record more then one place.

I will have to look at your code Edhy and see what you have done.
Edhy Rijo
E
StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Terry,

Basically this sample is expecting you have an Order field which they change in the datarow object and it is reflected in the grid because the grid is already ordered by that column named "Order" in their sample.

In your case that column is "JudgesSheetPositionNumber" so basically we would just do the same but at the BO level, assign the "JudgesSheetPositionNumber" value of the selected row to the value next or prior based on the Up/Down button but keep in mind that that will make the BO dirty and you will have to save it to keep the new position number by either asking the user or save it each time the position changes.

When using


' Assuming you are moving Down

Dim
 index As Integer = view.FocusedRowHandle
If index >= view.DataRowCount - 1 Then
      Return
End If

' Here create an instance of the BO with the record where the grid is focused
Dim
 boInGridView As New ResultsPerfsChecksTimedEventBO
boInGridView = TryCast(Me.GridView1.GetRow(index), ResultsPerfsChecksTimedEventBO1)
boInGridView.JudgesSheetPositionNumber = (boInGridView.JudgesSheetPositionNumber + 1)


Obviously you would need to add validations as to make sure when in 1st position you cannot move up or when at the end you cannot move down.

Try to make the functionality works moving Down and Up fist, then focus on make the Drag/Drop operations.

Please let me know if that works for you?

P.S.
Forgot t mention that this whole logic is based on the current sort order enforced in the grid by the sort column "JudgesSheetPositionNumber"  Without this sort in place you will not see the record being moved from one row to another in the grid.

gridView1.Columns("JudgesSheetPositionNumber").SortOrder = DevExpress.Data.ColumnSortOrder.Ascending         
gridView1.OptionsCustomization.AllowSort = False


Edhy Rijo

Edited 10 Years Ago by Edhy Rijo
Buffie
Buffie
StrataFrame User (271 reputation)StrataFrame User (271 reputation)StrataFrame User (271 reputation)StrataFrame User (271 reputation)StrataFrame User (271 reputation)StrataFrame User (271 reputation)StrataFrame User (271 reputation)StrataFrame User (271 reputation)StrataFrame User (271 reputation)
Group: StrataFrame Users
Posts: 119, Visits: 11K
thanks Edhy
Edhy Rijo
E
StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Terry,

I downloaded the demo yesterday but could not get back to it.

I will review it now with your code changes and get back in a few.

Edhy Rijo

Buffie
Buffie
StrataFrame User (271 reputation)StrataFrame User (271 reputation)StrataFrame User (271 reputation)StrataFrame User (271 reputation)StrataFrame User (271 reputation)StrataFrame User (271 reputation)StrataFrame User (271 reputation)StrataFrame User (271 reputation)StrataFrame User (271 reputation)
Group: StrataFrame Users
Posts: 119, Visits: 11K
Alright the Following Seems to Work but any ideas of a better way to do it or the Correct way to do it would be appreciated.

Dim row1 As DataRow = Me.ResultsPerfsChecksTimedEventBO1.CurrentRow()
Me.ResultsPerfsChecksTimedEventBO1.MovePrevious()
Dim row2 As DataRow = Me.ResultsPerfsChecksTimedEventBO1.CurrentRow()
Me.ResultsPerfsChecksTimedEventBO1.MoveNext()
Dim val1 As Object = row1("JudgesSheetPositionNumber")
Dim val2 As Object = row2("JudgesSheetPositionNumber")
row1("JudgesSheetPositionNumber") = val2
row2("JudgesSheetPositionNumber") = val1


Now on to the part of Mouse Drag and Drop.

 


Buffie
Buffie
StrataFrame User (271 reputation)StrataFrame User (271 reputation)StrataFrame User (271 reputation)StrataFrame User (271 reputation)StrataFrame User (271 reputation)StrataFrame User (271 reputation)StrataFrame User (271 reputation)StrataFrame User (271 reputation)StrataFrame User (271 reputation)
Group: StrataFrame Users
Posts: 119, Visits: 11K
This seems to get the correct DataRows. I am not sure it is the correct way to do it?????

Dim row1 As DataRow = Me.ResultsPerfsChecksTimedEventBO1.CurrentRow()
Me.ResultsPerfsChecksTimedEventBO1.MovePrevious()
Dim row2 As DataRow = Me.ResultsPerfsChecksTimedEventBO1.CurrentRow()
Me.ResultsPerfsChecksTimedEventBO1.MoveNext()


I have not figured out how to get the 'Val' values....?

TIA.


Buffie
Buffie
StrataFrame User (271 reputation)StrataFrame User (271 reputation)StrataFrame User (271 reputation)StrataFrame User (271 reputation)StrataFrame User (271 reputation)StrataFrame User (271 reputation)StrataFrame User (271 reputation)StrataFrame User (271 reputation)StrataFrame User (271 reputation)
Group: StrataFrame Users
Posts: 119, Visits: 11K
And by the way Edhy thanks for the help.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search