I'm using @coreui/react
with React-select
the problem is that returning a Select
element in scoped slots
breaks core-ui
functionalities like searching & sorting
However it works fine if when returning a <label>
or a <p>
with text Ex: <label>{item.status}</label>
Question
Why is Select component breaking the functionality ?
Any workaround / efforts are highly appreciated
Note
I have tried workarounds like <p hidden >{item.status}</p>
and then rendering the Select
component but it does not work
import React from "react";
import Select from "react-select";
import { CDataTable } from "@coreui/react";
...
<CDataTable
bordered
clickableRows
fields={fields}
hover
items={[...employeeData]}
itemsPerPage={10}
itemsPerPageSelect
loading={tableLoader}
onRowClick={(e) => rowSelectHandler(e)}
pagination
size="sm"
sorter={{ resetable: true }}
striped
tableFilter={{
placeholder: "Filter",
label: "Search:",
}}
scopedSlots={{
status: (item, index) => (
<td style={{ width: "13%" }}>
<Select
id={item.index}
placeholder="Select Status"
isSearchable={false}
className="basic-single"
onChange={(e) => selectChangeHandler(e.value, index)}
classNamePrefix="select"
defaultValue={{
label: item.status,
value: item.status,
color: getBadge(item.status),
}}
// name="color"
// inputValue={item.status}
options={[
{
value: "ACTIVE",
label: "ACTIVE",
color: "#2eb85c",
},
{
value: "DEACTIVE",
label: "DEACTIVE",
color: "#e55353",
},
]}
styles={colourStyles}
/>
</td>
),
}}
/>
...
Edit
Accepting answers with antd-select
also if it works with coreui-datatable
react-select
– Lobectomy<> <select .... /> </>
– Enslavepagination
status is static it does not change on page change that column stays the samesorting
is not working on that columnsearching
is not working either – Lobectomyselect
components is not possible , Also writing my own customselect
component is beyond me I think..... – Lobectomy