Comments (7)
i used your example, but i faced with another issue. if i set cellRenderer = EditableCell
for columns i do not have any problems and i do not need to have autoFocus
. but when i start use:
const components = {
TableCell: EditableCell,
};
i need to have autoFocus
and code seems to be broken:
const { Overlay } = ReactOverlays;
const CellContainer = styled.div`
display: flex;
flex: 1 0 100%;
align-items: center;
height: 100%;
width: 100%;
overflow: hidden;
margin: 0 -5px;
padding: 5px;
border: 1px dashed transparent;
`
const GlobalStyle = createGlobalStyle`
.BaseTable__row:hover,
.BaseTable__row--hover {
${CellContainer} {
border: 1px dashed #ccc;
}
}
`
const Input = styled.input`
width: 100%;
height: 30px;
margin-top: 10px;
`
export default () => {
const [getColumns, setColumns] = React.useState([]);
const [getData, setData] = React.useState([]);
const [isLoading, setLoading] = React.useState(true);
React.useEffect(() => {
if (isLoading) {
const columns = generateColumns(2);
const data = generateData(columns, 4);
setColumns(columns);
setData(data);
// columns.forEach(column => {
// column.cellRenderer = EditableCell
// });
setLoading(false);
}
}, [isLoading])
const updateCell = (value, cellProps) => {
setData(data => data.map(cell => cell.id == cellProps.rowData.id ?
{
...cell,
[cellProps.column.key]: value
}
: cell
));
}
const EditableCell = (cellProps) => {
handleChange = e => {
updateCell(e.target.value, cellProps)
}
return (
<Input autoFocus type="text" value={cellProps.cellData}
onChange={this.handleChange} />
);
};
if (isLoading)
return (<h1>loading...</h1>)
const components = {
TableCell: EditableCell,
};
return (
<>
<GlobalStyle />
<Table fixed
columns={getColumns}
data={getData}
components={components}
/>
</>
)
}
from react-base-table.
BTW, for input you don't need to use Overlay
actually unless you need to show validation message
from react-base-table.
@nihgwu ^
from react-base-table.
from react-base-table.
@nihgwu could you try to change some value at text input and then press tab
from react-base-table.
autoFocus
makes no sense here, it's used if the cell is plain text in normal mode and input in editing mode, and components
is considered to be a constant, but in your version it's changing all the time
BTW, I just modified your code to make it work, but actually it should not be implemented in that way
from react-base-table.
it works, thank you for your help
from react-base-table.
Related Issues (20)
- How to scroll to row after loading data in Infinite Loading?
- How to slide the header without data
- rowRenderer type: columns should be an array HOT 1
- Why am I experiencing scroll delay in my implementation when it looks smooth in the playground example HOT 2
- when there is a large amount of data, the function of unfolding and folding is abnormally stuck
- The resizing line goes beyond the list item area
- How to render (resize) the table on column resize end ?
- how always display SortIndicator not just have it when hovering the title?
- SortIndicator bug HOT 1
- Heavy Recalculate style stack in performance on scroll
- Selection of multiple rows not working with BaseTable componnent
- Detail View bug
- selections not working if columns pulled from state? HOT 1
- row height auto HOT 1
- Expand functionality (row grouping ) is not working as expected as given in example
- Can't perform a React state update on an unmounted component
- Draggable columns HOT 1
- When do you plan to upgrade to react-18? we've been using it for a few months now and without problems, but it's sending a lot of warnings and preventing 'npm i' or any other command in the terminal, being necessary to use '--force'
- Severe scroll lag HOT 11
- Is there a smooth scroll animation for applying on scroll methods?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-base-table.