React-native-swipe-list-view: How to close a given row, on (say) a button tap ?

Created on 14 Feb 2017  路  7Comments  路  Source: jemise111/react-native-swipe-list-view

hi, first thanks for the component its great.

need some quick guidance/example on how to programmatically close a row that is currently open/in delete mode? how can we do that from (say) a button press callback ? wasn't sure how to do this via ref's. We are using SwipeListView and SwipeRow

2017-02-14_13-06-31

Most helpful comment

Hey @ajonno. There is an instance method on the <SwipeListView /> called safeCloseOpenRow.
It's not documented because it isn't really intended to be public but I think it should do what you're looking for.

onButtonPress() {
  this._swipeListView.safeCloseOpenRow();
}

render () {
  <SwipeListView
    ref={ref => this._swipeListView = ref}
  />
}

Going to close this issue. Please reopen if this doesn't work and you're still having problems. If you'd like to add a section in the Readme please feel free to submit a PR. Thanks!

All 7 comments

hi, any tips on this would be appreciated. id be happy to update your docs also.

Hey @ajonno. There is an instance method on the <SwipeListView /> called safeCloseOpenRow.
It's not documented because it isn't really intended to be public but I think it should do what you're looking for.

onButtonPress() {
  this._swipeListView.safeCloseOpenRow();
}

render () {
  <SwipeListView
    ref={ref => this._swipeListView = ref}
  />
}

Going to close this issue. Please reopen if this doesn't work and you're still having problems. If you'd like to add a section in the Readme please feel free to submit a PR. Thanks!

Brilliant thank you so much. I reckon this would be a great method to include in main release.

Is it possible to open a row programmatically?

@jemise111 is there a method that has an indicator whether any row is opened or not ?

Nevermind, it was super easy to accomplish.

if (null !== this._openedRowKey) {
            this.closeRow(this._openedRowKey.rowMap, this._openedRowKey.rowKey)
            this._openedRowKey = null;
            return;
        }

Hey @ajonno. There is an instance method on the <SwipeListView /> called safeCloseOpenRow.
It's not documented because it isn't really intended to be public but I think it should do what you're looking for.

onButtonPress() {
  this._swipeListView.safeCloseOpenRow();
}

render () {
  <SwipeListView
    ref={ref => this._swipeListView = ref}
  />
}

Going to close this issue. Please reopen if this doesn't work and you're still having problems. If you'd like to add a section in the Readme please feel free to submit a PR. Thanks!

Thank You this is wonderful fix

Was this page helpful?
0 / 5 - 0 ratings

Related issues

baicuhaha picture baicuhaha  路  6Comments

jjhesk picture jjhesk  路  3Comments

benoitvallon picture benoitvallon  路  6Comments

kopax picture kopax  路  4Comments

ramisalem picture ramisalem  路  5Comments