Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drag and drop to reorder rows #40

Open
kvenkata1974 opened this issue Aug 7, 2019 · 3 comments
Open

Drag and drop to reorder rows #40

kvenkata1974 opened this issue Aug 7, 2019 · 3 comments

Comments

@kvenkata1974
Copy link

Hi,
I'm using version 0.8 of SwiftDataTables.

Can the rows not be reorder via drag and drop?

Was hoping the delegate would allow for drag and drop of rows.

Cheers
Karthik

@kvenkata1974
Copy link
Author

I should be using the drag and drop delegate of the collection view, will try that first.

@kvenkata1974
Copy link
Author

kvenkata1974 commented Aug 7, 2019

Sorry, tried using UICollectionViewDelegate and implemented the methods (extended SwiftDataTable since it already implements the protocol):

func collectionView(_ collectionView: UICollectionView, canFocusItemAt indexPath: IndexPath) -> Bool {
    return true
}

func collectionView(_ collectionView: UICollectionView, moveItemAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath) {
    print("Starting Index: \(sourceIndexPath.item)")
    print("Ending Index: \(destinationIndexPath.item)")
}

But I could not get reorder of items via drag and drop to be triggered. Please help.

@kvenkata1974 kvenkata1974 reopened this Aug 7, 2019
@pavankataria
Copy link
Owner

pavankataria commented Aug 14, 2019

Yeah I didn't have this in mind and not sure how adopting those methods will affect the ordering of the swift data tables datasource. Come to think of it, I believe you'll need to update the datasource yourself once you figure out where the user wants to drag and drop an item. You'll then need to refresh the collection view to reflect the changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants