react-native-sortable-list
react-native-sortable-list copied to clipboard
disable sorting for specific row
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
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>
)}
/>
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.
Could you render two different lists? One with your disabled items on top and another using SortableList with the active items.
there is no onPressIn method for the TouchableOpacity how can we achieve this.
@mohanraj546 Are you sure? TouchaleOpacity extends the TouchableWithoutFeedback props, which includes onPressIn
https://facebook.github.io/react-native/docs/touchableopacity#props