// imports and interfaces..
const RowDragHandleCell = ({ rowId }: { rowId: string }) => {
const { attributes, listeners } = useSortable({
id: rowId,
});
return (
// Alternatively, you could set these attributes on the rows themselves
<button {...attributes} {...listeners}>
🟰
</button>
);
};
const DraggableRow = ({ row }: { row: Row<ProjectType> }) => {
console.log("DraggableRow::RowID: ", row.id);
const { transform, transition, setNodeRef, isDragging } = useSortable({
id: row.original.order_nr,
});
const style: CSSProperties = {
transform: CSS.Transform.toString(transform), //let dnd-kit do its thing
transition: transition,
opacity: isDragging ? 0.8 : 1,
zIndex: isDragging ? 1 : 0,
position: "relative",
};
return (
// connect row ref to dnd-kit, apply important styles
<tr ref={setNodeRef} style={style}>
{row.getVisibleCells().map((cell) => (
<td key={cell.id} style={{ width: cell.column.getSize() }}>
{flexRender(cell.column.columnDef.cell, cell.getContext())}
</td>
))}
</tr>
);
};
// imports and interfaces..
const RowDragHandleCell = ({ rowId }: { rowId: string }) => {
const { attributes, listeners } = useSortable({
id: rowId,
});
return (
// Alternatively, you could set these attributes on the rows themselves
<button {...attributes} {...listeners}>
🟰
</button>
);
};
const DraggableRow = ({ row }: { row: Row<ProjectType> }) => {
console.log("DraggableRow::RowID: ", row.id);
const { transform, transition, setNodeRef, isDragging } = useSortable({
id: row.original.order_nr,
});
const style: CSSProperties = {
transform: CSS.Transform.toString(transform), //let dnd-kit do its thing
transition: transition,
opacity: isDragging ? 0.8 : 1,
zIndex: isDragging ? 1 : 0,
position: "relative",
};
return (
// connect row ref to dnd-kit, apply important styles
<tr ref={setNodeRef} style={style}>
{row.getVisibleCells().map((cell) => (
<td key={cell.id} style={{ width: cell.column.getSize() }}>
{flexRender(cell.column.columnDef.cell, cell.getContext())}
</td>
))}
</tr>
);
};