【问题标题】:MUI AUTOCOMPLETE NOT FILTERINGMUI 自动完成不过滤
【发布时间】:2022-08-23 16:22:04
【问题描述】:

当我在文本字段中输入字符串的一部分时,如果我输入 112,下拉列表中的选项不会被过滤,它不会仅显示带有 112 的值,它会显示所有选项。

 <Autocomplete
      disabled={row.group_mapping_id && !(\'editClicked\' in row)}
      freeSolo
      value={row.client_id} 
      onChange={(event, newValue) => props.onChangeTableInput(\'client_id\', index, newValue, row)}
      options={props.clientDetails}
      getOptionLabel={(option) => {
          if (typeof option === \'string\') {
             return option;
          }
          return option.client_id;
     }}
     style={{width: \'120px\'}}
     disableClearable
     renderInput={(params) => <TextField {...params} 
                   variant=\'outlined\'
                   inputProps={{
                      ...params.inputProps,
                      autoComplete: \"disabled\",
                      type: \'search\'
                   }} />}
    />
   props.clientDetails ,[
    {client_master_id: 73, client_id: \"OM112\", client_name: \"AOP\"},…]
    {client_master_id: 73, client_id: \"OH112\", client_name: \"AKI\"}
    {client_master_id: 74, client_id: \"OL112\", client_name: \"AJU2\"}
    {client_master_id: 75, client_id: \"OLO112\", client_name: \"ABG4\"}
    {client_master_id: 80, client_id: \"OM912\", client_name: \"ACVGh\"}
    ]

    标签: reactjs material-ui autocomplete


    【解决方案1】:

    尝试将 filterOptions 道具添加到自动完成组件 像这样的东西: filterOptions={(x) => x}

    【讨论】:

      猜你喜欢
      • 2021-12-25
      • 1970-01-01
      • 2020-05-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-13
      • 2023-04-05
      • 1970-01-01
      相关资源
      最近更新 更多