react-Widgets:从onSearch(Multiselect)返回什么

时间:2016-10-06 13:50:15

标签: javascript reactjs

我正在尝试将onSearchMultiselect的反应小部件一起使用。我可以看到使用onSearch调用searchTerm。但是,响应永远不会成为Multiselect的选项/数据的一部分。

我尝试将结果返回到数组或带有键data的对象中的数组。

const getOptions = searchTerm => {
  return [{ _id: 1, username: 'Bob' }];
}

const TagItem = ({ username }) => <span>{username}</span>

const MultiSelectUsers = ({ input, ...rest }) =>
  <Multiselect {...input}
    onBlur={() => input.onBlur()}
    value={input.value || []}
    valueField="_id"
    tagComponent={TagItem}
    itemComponent={TagItem}
    onSearch={getOptions}
    {...rest}
  />

额外奖励:如何使用带有Promise的onSearch?

1 个答案:

答案 0 :(得分:0)

这里需要做一些事情。

1)@mixin mytheme { @include valo; // Insert your own theme rules here .v-table [class*="-row-no-background"].v-selected { background: transparent none; // no colour & no image color: black; // make the text visible as default selection makes it white } } 仅调用回调,即它不会更新任何内容。更新需要通过onSearch完成。 (例如,在data中使用状态)

2)诀窍是#1不会起作用,除非你在MultiSelectUsers中设置filter={false}