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

if renderCell used, api should apply the <View> wrapper with styles to the result #5

Open
pstanton opened this issue Jan 16, 2018 · 1 comment

Comments

@pstanton
Copy link

pstanton commented Jan 16, 2018

If you use the 'renderCell' property, you cannot make the result look like a table since the column width and styles are not accessible and are not applied to the returned markup.

'renderCell' should override only the portion of the api's _renderCell function that returns the <Text/> element.

@pstanton
Copy link
Author

pstanton commented Jan 16, 2018

	_renderCell(cellData, col) {
		let style = { width: col.width || this.props.columnWidth || DEFAULT_COLUMN_WIDTH };
		// call 'renderCell' which can return false to fall back to default implementation
		let content = this.props.renderCell
			? this.props.renderCell(cellData, col)
			: false;
		if (!content) content = <Text>{cellData}</Text>;
		return (
			<View key={col.dataIndex} style={[styles.cell, style]}>
				{content}
			</View>
		);
	}
	_renderRow(rowData, index) {
		let { columns } = this.props;
		let renderCell = this._renderCell.bind(this);
		return (
			<View key={index} style={styles.row}>
				{columns.map(col => renderCell(rowData[col.dataIndex], col))}
			</View>
		);
	}

this change also allows 'renderCell' to return false if the default behaviour is required (ie <Text/>)

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

No branches or pull requests

1 participant