RE-ordering items in a collection field - UI Model Help Needed!
I'm building a data form which contains a collection field, and I've added some UI Action buttons to move items up and down in the collection.
But this is where I'm stuck, I have no idea what to do in the UI Model. This is as far as I've gotten
But this is where I'm stuck, I have no idea what to do in the UI Model. This is as far as I've gotten
Private Sub _btnmoveup_InvokeAction(sender As Object, e As InvokeActionEventArgs) Handles _btnmoveup.InvokeAction
End Sub
Private Sub _btnmovedown_InvokeAction(sender As Object, e As InvokeActionEventArgs) Handles _btnmovedown.InvokeAction
End Sub
Not having much luck finding example code.
1
Comments
-
Hi Rick,
I saw this the other day, and I thought I'd throw together a quick demo. It turns out it's harder than it looks.
What I have below doesn't quite work, but I don't know why yet.
I thought it might give you ideas.
If someone has a working example, I'd love to see it. Likewise, if I get it to work, I'll add to this post.
Given this collection:
<FormField FieldID="LOCATIONS" Caption="Locations" DataType="XML">
<Collection>
<Fields>
<FormField FieldID="NAME" DataType="String" Caption="Name"/>
<FormField FieldID="COUNTRYID" DataType="Guid" Caption="Country">
<SimpleDataList SimpleDataListID="c9649672-353d-42e8-8c25-4d34bbabfbba"/>
</FormField>
<FormField FieldID="STATEID" DataType="Guid" Caption="State">
<SimpleDataList SimpleDataListID="b46d36d1-d3ed-4f6e-91da-89b6c88ca0c6">
<Params>
<Param ID="COUNTRYID">
<Value>Fields!COUNTRYID</Value>
</Param>
</Params>
</SimpleDataList>
</FormField>
</Fields>
</Collection>
</FormField>And these UIActions
<UIActions>
<UIAction ActionID="MOVEUP" Caption="Move up"/>
<UIAction ActionID="MOVDOWN" Caption="Move down"/>
</UIActions>This code should move the selected row up (but it doesn't)
Private Sub _moveup_InvokeAction(sender As Object, e As InvokeActionEventArgs) Handles _moveup.InvokeAction
Dim selectedIndex = GetSelectedRowIndex()
If 0 < selectedIndex Then '0 because you can't move the top row up any further
Dim replacedRow = LOCATIONS.Value(selectedIndex - 1)
LOCATIONS.Value(selectedIndex - 1) = LOCATIONS.Value(selectedIndex)
LOCATIONS.Value(selectedIndex) = replacedRow
End If
End Sub
Private Function GetSelectedRowIndex() As Integer
For i As Integer = 0 To LOCATIONS.Value.Count
If LOCATIONS.Value(i).Selected Then
Return i
End If
Next
Return -1
End FunctionJoseph Styons
https://www.styonssoftware.com0 -
You gave me enough to get it working! Just had to use the methods.... THANK YOU!
Private Sub _btnmoveup_InvokeAction(sender As Object, e As InvokeActionEventArgs) Handles _btnmoveup.InvokeAction
Dim selectedIndex = GetSelectedRowIndex()
If selectedIndex > 0 Then '0 because you can't move the top row up any further
Dim rowToMove = FUNDS.Value(selectedIndex)
FUNDS.Value.RemoveAt(selectedIndex) 'remove the selected item
FUNDS.Value.Insert(selectedIndex - 1, rowToMove) ' then insert it one hgiher.
End If
End Sub
Private Sub _btnmovedown_InvokeAction(sender As Object, e As InvokeActionEventArgs) Handles _btnmovedown.InvokeAction
Dim selectedIndex = GetSelectedRowIndex()
If selectedIndex < FUNDS.Value.Count - 1 Then
Dim rowToMove = FUNDS.Value(selectedIndex)
FUNDS.Value.RemoveAt(selectedIndex) 'remove the selected item
FUNDS.Value.Insert(selectedIndex + 1, rowToMove) ' then insert it one hgiher.
End If
End Sub
Private Function GetSelectedRowIndex() As Integer
For i As Integer = 0 To FUNDS.Value.Count
If FUNDS.Value(i).Selected Then
Return i
End If
Next
Return -1
End Function0
Categories
- All Categories
- 6 Blackbaud Community Help
- 213 bbcon®
- 1.4K Blackbaud Altru®
- 403 Blackbaud Award Management™ and Blackbaud Stewardship Management™
- 1.2K Blackbaud CRM™ and Blackbaud Internet Solutions™
- 15 donorCentrics®
- 360 Blackbaud eTapestry®
- 2.6K Blackbaud Financial Edge NXT®
- 656 Blackbaud Grantmaking™
- 577 Blackbaud Education Management Solutions for Higher Education
- 3.2K Blackbaud Education Management Solutions for K-12 Schools
- 940 Blackbaud Luminate Online® and Blackbaud TeamRaiser®
- 84 JustGiving® from Blackbaud®
- 6.7K Blackbaud Raiser's Edge NXT®
- 3.7K SKY Developer
- 249 ResearchPoint™
- 119 Blackbaud Tuition Management™
- 165 Organizational Best Practices
- 241 Member Lounge (Just for Fun)
- 34 Blackbaud Community Challenges
- 37 PowerUp Challenges
- 3 (Open) PowerUp Challenge: Grid View Batch
- 3 (Closed) PowerUp Challenge: Chat for Blackbaud AI
- 3 (Closed) PowerUp Challenge: Data Health
- 3 (Closed) Raiser's Edge NXT PowerUp Challenge: Product Update Briefing
- 3 (Closed) Raiser's Edge NXT PowerUp Challenge: Standard Reports+
- 3 (Closed) Raiser's Edge NXT PowerUp Challenge: Email Marketing
- 3 (Closed) Raiser's Edge NXT PowerUp Challenge: Gift Management
- 4 (Closed) Raiser's Edge NXT PowerUp Challenge: Event Management
- 3 (Closed) Raiser's Edge NXT PowerUp Challenge: Home Page
- 4 (Closed) Raiser's Edge NXT PowerUp Challenge: Standard Reports
- 4 (Closed) Raiser's Edge NXT PowerUp Challenge: Query
- 796 Community News
- 3K Jobs Board
- 54 Blackbaud SKY® Reporting Announcements
- 47 Blackbaud CRM Higher Ed Product Advisory Group (HE PAG)
- 19 Blackbaud CRM Product Advisory Group (BBCRM PAG)

