Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions RNTableView/RNTableView.m
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,15 @@ - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEd

[_sections[indexPath.section][@"items"] removeObjectAtIndex:indexPath.row];
[self.tableView reloadData];
} else if (editingStyle == UITableViewCellEditingStyleInsert) {
NSMutableDictionary *newValue = [self dataForRow:indexPath.item section:indexPath.section];
newValue[@"target"] = self.reactTag;
newValue[@"selectedIndex"] = [NSNumber numberWithInteger:indexPath.item];
newValue[@"selectedSection"] = [NSNumber numberWithInteger:indexPath.section];
newValue[@"mode"] = @"insert";

self.onChange(newValue);
[self.tableView reloadData];
}
}

Expand Down
20 changes: 15 additions & 5 deletions example/src/screens/Example6.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import PropTypes from 'prop-types'
import { View, Button } from 'react-native'
import TableView from 'react-native-tableview'

const { Item, Section } = TableView
const { Item, Section, Consts } = TableView

class Example6 extends React.Component {
static navigationOptions = ({ navigation }) => ({
Expand Down Expand Up @@ -34,10 +34,20 @@ class Example6 extends React.Component {
<Item>Item 2</Item>
<Item>Item 3</Item>
<Item>Item 4</Item>
<Item>Item 5</Item>
<Item>Item 6</Item>
<Item>Item 7</Item>
<Item>Item 8</Item>
</Section>
</TableView>
<TableView
style={{ flex: 1 }}
editing={this.props.navigation.state.params.editing}
tableViewCellEditingStyle={Consts.CellEditingStyle.Insert}
onPress={event => alert(JSON.stringify(event))}
onChange={event => alert(`CHANGED:${JSON.stringify(event)}`)}
>
<Section canMove canEdit>
<Item canEdit={false}>Item 1</Item>
<Item>Item 2</Item>
<Item>Item 3</Item>
<Item>Item 4</Item>
</Section>
</TableView>
</View>
Expand Down