react-component / tree-select

React Tree Select
https://tree-select.react-component.now.sh/
MIT License
290 stars 190 forks source link

how can I make form Item with treeSelect ‘readOnly’ #86

Open neewbee opened 6 years ago

neewbee commented 6 years ago

image

disabled the item and treeSelect won't work disabled the three nodes , you still can delete the selected nodes by click the x icon

yesmeck commented 6 years ago

You can control the value by onChange callback, any nodes you don't want to change, just do not any change in onChange.

neewbee commented 6 years ago

I have tried onChange:(value, label, extra) => { setFieldsValue({"treeSelect":extra.preValue }) } doesn't work. Should I return prevValue in onChange ?

yesmeck commented 6 years ago

Just ignore the change.

onChange(value) {
  if (readOnly(value)) {
    return;
  }
}
neewbee commented 6 years ago

Do you mean adding onChange:() => { return null } at line https://github.com/react-component/tree-select/blob/36c14ea7766eeffc75dd34315af44b9a7253e7a4/examples/form.js#L59 ?