Skip to content

Commit

Permalink
fix picker multicolumn with same key bug
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisHchen committed Aug 30, 2017
1 parent 3bae2ec commit d72edb7
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 5 deletions.
11 changes: 6 additions & 5 deletions components/Picker/Picker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,12 @@ class Picker extends Component {
}
}

let treeChildren2 = this.props.dataSource.reduce((a, b) => {
return a.concat(b);
}, []);
treeChildren2 = treeChildren2.filter((item) => { return ~value.indexOf(item[valueMember]); });

const treeChildren2 = data.map((d, index) => {
if (value[index]) {
return d.find(obj => value[index] === obj[valueMember]);
}
return undefined;
}).filter(t => !!t);
return this._displayRender(treeChildren2);
};

Expand Down
55 changes: 55 additions & 0 deletions examples/pages/Test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import React, { Component } from 'react';
import Container from '../components/Container';
import Header from '../components/Header';
import Footer from '../components/Footer';
import { Picker } from '../../components';
import '../styles/pages/BadgePage';

class Page extends Component {
state = {
single:{}
}
render() {
const {single} = this.state
return (
<Container className="test">
<Header title="Test" />
<main>
<Picker
visible={single.visible}
dataSource={[
{
idCardType: 1,
idCardName: '身份证',
},
{
idCardType: 2,
idCardName: '护照',
},
{
idCardType: 3,
idCardName: '出生证',
},
]}
value={single.value}
displayMember="idCardName"
valueMember="idCardType"
onOk={(value) => {
console.log('pickerPage onOk ->', value);
const _value = value.idCardType;
single.value = _value;
this.setState({
single,
});
}}
onCancel={() => {
}}
/>
</main>
<Footer />
</Container>
);
}
}

export default Page;

0 comments on commit d72edb7

Please sign in to comment.