Angular/ts row dragging from one grid to another grouped row grid

I am trying to find a solution to row drag a row from grid 1 to a grouped row in grid 2.

For example:

Grid 1 has address information: Street, number, city

Grid 2 has type + address information: Type, street, number, city
Grid 2 is grouped by type so the address information is grouped/attached to a specific type.

I want to drag the address information from grid 1 under a grouped row (for example type 1) and it should be added under the grouped row type 1

I tried to find out if this is possible with the Enterprise version of ag grid. Sadly I can only find you can row drag to another grid and you can group rows. But there is no example of how to row drag to a grouped row. Since for my knowledge you only have applyTransaction Add/remove but not on a grouped row.

Can someone correct me if i’m wrong and maybe could provide a example of how to achieve this?

New contributor

Sven is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

It sounds like you’re looking to combine row drag and drop functionality with grouping in AG Grid, specifically to drag rows from one grid to another while maintaining their grouping. This can indeed be achieved using AG Grid’s Enterprise version, but it requires some custom logic because the default examples often deal with basic row drag and drop between grids without grouping considerations.

a/c to me : you should try enabling row drag across grids:
In Grid 1, set the rowDrag property for the column where dragging will happen.

 {
    field: 'street',
    rowDrag: true,
  }

In Grid 2, you’ll already have rows grouped by type (Type 1, Type 2, etc.). Use the grouping feature of AG Grid:

 {
    groupDisplayType: 'groupRows',
    rowGroup: true,
  }

Since AG Grid doesn’t natively handle dropping rows into grouped rows, you’ll need to listen for the drop event and then manually apply the transaction to insert the dropped row into the correct group.

To achieve this, you’ll listen for a rowDragEnd event on Grid 1 and then programmatically determine where to insert the row into Grid 2 based on the grouping.

Here’s how you can do it (this shall work ):

// Grid 1 (Source Grid)
const gridOptions1 = {
  columnDefs: [
    { field: 'street', rowDrag: true },
    { field: 'number' },
    { field: 'city' }
  ],
  onRowDragEnd: function(event) {
    const draggedData = event.node.data;
    
    // Custom logic to figure out which group the row was dropped on
    const groupType = 'Type 1'; // You need to determine this dynamically

    const transaction = {
      add: [{
        type: groupType,
        street: draggedData.street,
        number: draggedData.number,
        city: draggedData.city
      }]
    };
    
    gridOptions2.api.applyTransaction(transaction);
  }
};

// Grid 2 (Target Grid)
const gridOptions2 = {
  columnDefs: [
    { field: 'type', rowGroup: true },
    { field: 'street' },
    { field: 'number' },
    { field: 'city' }
  ],
  defaultColDef: {
    flex: 1,
    minWidth: 100,
    resizable: true
  },
  groupDisplayType: 'groupRows',
  rowData: initialDataForGrid2
};

Summary of Steps:

  1. Enable rowDrag in Grid 1.
  2. Enable grouping in Grid 2.
  3. Listen for the rowDragEnd event in Grid 1.
  4. Determine the target group in Grid 2 based on where the row was
    dropped.
  5. Use applyTransaction in Grid 2 to add the new row under
    the correct group.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật