Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Attempt at Row DnD implementation on @tanstack/solid-table #121

Copy link
Copy link
@Koning3ton

Description

@Koning3ton
Issue body actions

Hello,

Thanks for this great library!
I'm trying to implement the Row DnD example for React for the SolidJS version.

Below my current implementation can be found. Feedback always welcome!

Code can be found on StackBlitz.

I also include the DraggableRow implementation of my code example here for completeness:

import { flexRender } from '@tanstack/solid-table';
import {
  createSortable,
  useDragDropContext,
  transformStyle,
} from '@thisbeyond/solid-dnd';

// Row Component shown when row is dragged
const DraggableRow = ({ row, className }: { row: any; className?: string }) => {
  const sortable = createSortable(row.original.id);
  const context = useDragDropContext();
  const state = context && context[0];

  return (
    <tr
      ref={sortable.ref}
      class={className}
      style={transformStyle(sortable.transform)}
      classList={{
        'opacity-25': sortable.isActiveDraggable,
        'transition-transform': !!state?.active.overlay,
      }}
    >
      {row.getVisibleCells().map((cell: any, idx: number) =>
        cell.column.id == 'drag-handle' ? ( // Only the Drag handle should allow the row to be dragged.
          <td
            {...sortable.dragActivators}
            class="border border-border"
            style={{ height: '1px', width: cell.column.getSize() + 'px' }}
          >
            {flexRender(cell.column.columnDef.cell, cell.getContext())}
          </td>
        ) : (
          <td
            class="border border-border"
            style={{ height: '1px', width: cell.column.getSize() + 'px' }}
          >
            {flexRender(cell.column.columnDef.cell, cell.getContext())}
          </td>
        )
      )}
    </tr>
  );
};
export default DraggableRow;
Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.