react-native-sortable-list icon indicating copy to clipboard operation
react-native-sortable-list copied to clipboard

disable sorting for specific row

Open aliraza8404 opened this issue 6 years ago • 5 comments

how can i disable specific rows so that one can not sort these specific rows while other rows will remain sortable.

manuallyActivateRows(using this prop cause to disable all rows)

so how can i use [this.props.toggleRowActive()] prop to enable sorting for specific rows. @gitim

aliraza8404 avatar Mar 08 '18 12:03 aliraza8404

If you have manuallyActivateRows turned on you will need to pass toggleRowActive to a Touchable component inside the renderRow.

Something like this:

<SortaleListView
  data={{ one: 1, two: 2, three: 3 ]}
  manuallyActivateRows
  renderRow={({ data, toggleRowActive }) => (
    <TouchableOpacity onPressIn={toggleRowActive}>
      <View>{data}</View>
    </TouchableOpacity>
   )}
/>

So if you wanted some of the rows to be disabled, you could just specify that in the data you're passing so that you can act upon it:

<SortaleListView
  data={{ one: { val: 1 }, two: { val: 2 }, three: { val: 3, disabled: true } ]}
  manuallyActivateRows
  renderRow={({ val, toggleRowActive, disabled }) => (
    <TouchableOpacity onPressIn={diabled && toggleRowActive}>
      <View>{val}</View>
    </TouchableOpacity>
  )}
/>

jcurtis avatar Mar 15 '18 01:03 jcurtis

great its worked for me ......

one thing more is there any way that I disable normal items to swipe over these disable items... as in my case disabled items are at the top.

thanks in advance.

aliraza8404 avatar Mar 26 '18 09:03 aliraza8404

Could you render two different lists? One with your disabled items on top and another using SortableList with the active items.

jcurtis avatar Apr 02 '18 20:04 jcurtis

there is no onPressIn method for the TouchableOpacity how can we achieve this.

mohanraj546 avatar Nov 28 '18 05:11 mohanraj546

@mohanraj546 Are you sure? TouchaleOpacity extends the TouchableWithoutFeedback props, which includes onPressIn

https://facebook.github.io/react-native/docs/touchableopacity#props

jcurtis avatar Dec 01 '18 15:12 jcurtis