Important Note
When dragging a group, the plugin ensures that all columns in the group move together. You cannot drag individual columns out of a group using this plugin - the group integrity is maintained throughout the operation.
The Column Move Advanced plugin allows you to drag and drop entire column groups while maintaining group integrity. When you drag a group header, all columns within that group move together, and the plugin automatically updates group indexes at all levels.
import {
ColumnMoveAdvancedPlugin,
RowOddPlugin,
columnTypeRenderer,
} from '@revolist/revogrid-pro';
import { defineCustomElements } from '@revolist/revogrid/loader';
defineCustomElements();
const grid = document.querySelector('revo-grid');
if (grid) {
grid.colSize = 120;
grid.source = [
{
firstName: 'John',
lastName: 'Doe',
age: 30,
street: '123 Main St',
city: 'New York',
country: 'USA',
email: '[email protected]',
phone: '123-456-7890',
mobile: '098-765-4321',
},
{
firstName: 'Jane',
lastName: 'Smith',
age: 28,
street: '456 Oak Ave',
city: 'São Paulo',
country: 'Brazil',
email: '[email protected]',
phone: '234-567-8901',
mobile: '987-654-3210',
},
{
firstName: 'Bob',
lastName: 'Johnson',
age: 35,
street: '789 Pine Rd',
city: 'Madrid',
country: 'Spain',
email: '[email protected]',
phone: '345-678-9012',
mobile: '876-543-2109',
},
{
firstName: 'Alice',
lastName: 'Williams',
age: 32,
street: '321 Elm St',
city: 'London',
country: 'UK',
email: '[email protected]',
phone: '456-789-0123',
mobile: '765-432-1098',
},
];
grid.columns = [
{
name: 'Personal Information',
columnTemplate: columnTypeRenderer,
children: [
{
prop: 'firstName',
name: 'First Name',
size: 125,
},
{
prop: 'lastName',
name: 'Last Name',
},
{
prop: 'age',
name: 'Age',
},
],
},
{
name: 'Address',
columnType: 'id',
columnTemplate: columnTypeRenderer,
children: [
{
prop: 'street',
name: 'Street',
size: 155,
},
{
prop: 'city',
name: 'City',
},
{
prop: 'country',
name: 'Country',
},
],
},
{
name: 'Contact',
columnType: 'integer',
columnTemplate: columnTypeRenderer,
children: [
{
prop: 'email',
name: 'Email',
},
{
prop: 'phone',
name: 'Phone',
},
{
prop: 'mobile',
name: 'Mobile',
},
],
},
];
grid.plugins = [ColumnMoveAdvancedPlugin, RowOddPlugin];
grid.theme = 'material';
}
import React from 'react';
import { RevoGrid } from '@revolist/react-datagrid';
import {
ColumnMoveAdvancedPlugin,
RowOddPlugin,
columnTypeRenderer,
} from '@revolist/revogrid-pro';
import { currentTheme } from '../composables/useRandomData';
const ColumnMoveWithGroups: React.FC = () => {
const { isDark } = currentTheme();
const source = [
{
firstName: 'John',
lastName: 'Doe',
age: 30,
street: '123 Main St',
city: 'New York',
country: 'USA',
email: '[email protected]',
phone: '123-456-7890',
mobile: '098-765-4321',
},
{
firstName: 'Jane',
lastName: 'Smith',
age: 28,
street: '456 Oak Ave',
city: 'São Paulo',
country: 'Brazil',
email: '[email protected]',
phone: '234-567-8901',
mobile: '987-654-3210',
},
{
firstName: 'Bob',
lastName: 'Johnson',
age: 35,
street: '789 Pine Rd',
city: 'Madrid',
country: 'Spain',
email: '[email protected]',
phone: '345-678-9012',
mobile: '876-543-2109',
},
{
firstName: 'Alice',
lastName: 'Williams',
age: 32,
street: '321 Elm St',
city: 'London',
country: 'UK',
email: '[email protected]',
phone: '456-789-0123',
mobile: '765-432-1098',
},
];
const columns = [
{
name: 'Personal Information',
columnTemplate: columnTypeRenderer,
children: [
{
prop: 'firstName',
name: 'First Name',
size: 125,
},
{
prop: 'lastName',
name: 'Last Name',
},
{
prop: 'age',
name: 'Age',
},
],
},
{
name: 'Address',
columnType: 'id',
columnTemplate: columnTypeRenderer,
children: [
{
prop: 'street',
name: 'Street',
size: 155,
},
{
prop: 'city',
name: 'City',
},
{
prop: 'country',
name: 'Country',
},
],
},
{
name: 'Contact',
columnType: 'integer',
columnTemplate: columnTypeRenderer,
children: [
{
prop: 'email',
name: 'Email',
},
{
prop: 'phone',
name: 'Phone',
},
{
prop: 'mobile',
name: 'Mobile',
},
],
},
];
const plugins = [ColumnMoveAdvancedPlugin, RowOddPlugin];
return (
<RevoGrid
className="grow h-full cell-border"
source={source}
columns={columns}
plugins={plugins}
resize
hide-attribution
theme={isDark() ? 'darkMaterial' : 'material'}
style={{ minHeight: '300px' }}
/>
);
};
export default ColumnMoveWithGroups;
<template>
<RevoGrid
class="grow h-full cell-border"
:theme="isDark ? 'darkMaterial' : 'material'"
:columns="columns"
:source="source"
:plugins="plugins"
hide-attribution
style="min-height: 300px;"
/>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import RevoGrid from '@revolist/vue3-datagrid';
import {
ColumnMoveAdvancedPlugin,
RowOddPlugin,
columnTypeRenderer,
} from '@revolist/revogrid-pro';
import { currentThemeVue } from '../composables/useRandomData';
const { isDark } = currentThemeVue();
const source = ref([
{
firstName: 'John',
lastName: 'Doe',
age: 30,
street: '123 Main St',
city: 'New York',
country: 'USA',
email: '[email protected]',
phone: '123-456-7890',
mobile: '098-765-4321',
},
{
firstName: 'Jane',
lastName: 'Smith',
age: 28,
street: '456 Oak Ave',
city: 'São Paulo',
country: 'Brazil',
email: '[email protected]',
phone: '234-567-8901',
mobile: '987-654-3210',
},
{
firstName: 'Bob',
lastName: 'Johnson',
age: 35,
street: '789 Pine Rd',
city: 'Madrid',
country: 'Spain',
email: '[email protected]',
phone: '345-678-9012',
mobile: '876-543-2109',
},
{
firstName: 'Alice',
lastName: 'Williams',
age: 32,
street: '321 Elm St',
city: 'London',
country: 'UK',
email: '[email protected]',
phone: '456-789-0123',
mobile: '765-432-1098',
},
]);
const columns = ref([
{
name: 'Personal Information',
columnTemplate: columnTypeRenderer,
children: [
{
prop: 'firstName',
name: 'First Name',
size: 125,
},
{
prop: 'lastName',
name: 'Last Name',
},
{
prop: 'age',
name: 'Age',
},
],
},
{
name: 'Address',
columnType: 'id',
columnTemplate: columnTypeRenderer,
children: [
{
prop: 'street',
name: 'Street',
size: 155,
},
{
prop: 'city',
name: 'City',
},
{
prop: 'country',
name: 'Country',
},
],
},
{
name: 'Contact',
columnType: 'integer',
columnTemplate: columnTypeRenderer,
children: [
{
prop: 'email',
name: 'Email',
},
{
prop: 'phone',
name: 'Phone',
},
{
prop: 'mobile',
name: 'Mobile',
},
],
},
]);
const plugins = [ColumnMoveAdvancedPlugin, RowOddPlugin];
</script>
import { Component } from '@angular/core';
import { RevoGrid } from '@revolist/angular-datagrid';
import {
ColumnMoveAdvancedPlugin,
RowOddPlugin,
columnTypeRenderer,
} from '@revolist/revogrid-pro';
@Component({
selector: 'app-column-move-with-groups',
standalone: true,
imports: [RevoGrid],
template: `
<revo-grid
class="grow h-full cell-border"
[source]="source"
[columns]="columns"
[plugins]="plugins"
resize
hide-attribution
style="min-height: 300px;"
></revo-grid>
`,
})
export class ColumnMoveWithGroupsComponent {
source = [
{
firstName: 'John',
lastName: 'Doe',
age: 30,
street: '123 Main St',
city: 'New York',
country: 'USA',
email: '[email protected]',
phone: '123-456-7890',
mobile: '098-765-4321',
},
{
firstName: 'Jane',
lastName: 'Smith',
age: 28,
street: '456 Oak Ave',
city: 'São Paulo',
country: 'Brazil',
email: '[email protected]',
phone: '234-567-8901',
mobile: '987-654-3210',
},
{
firstName: 'Bob',
lastName: 'Johnson',
age: 35,
street: '789 Pine Rd',
city: 'Madrid',
country: 'Spain',
email: '[email protected]',
phone: '345-678-9012',
mobile: '876-543-2109',
},
{
firstName: 'Alice',
lastName: 'Williams',
age: 32,
street: '321 Elm St',
city: 'London',
country: 'UK',
email: '[email protected]',
phone: '456-789-0123',
mobile: '765-432-1098',
},
];
columns = [
{
name: 'Personal Information',
columnTemplate: columnTypeRenderer,
children: [
{
prop: 'firstName',
name: 'First Name',
size: 125,
},
{
prop: 'lastName',
name: 'Last Name',
},
{
prop: 'age',
name: 'Age',
},
],
},
{
name: 'Address',
columnType: 'id',
columnTemplate: columnTypeRenderer,
children: [
{
prop: 'street',
name: 'Street',
size: 155,
},
{
prop: 'city',
name: 'City',
},
{
prop: 'country',
name: 'Country',
},
],
},
{
name: 'Contact',
columnType: 'integer',
columnTemplate: columnTypeRenderer,
children: [
{
prop: 'email',
name: 'Email',
},
{
prop: 'phone',
name: 'Phone',
},
{
prop: 'mobile',
name: 'Mobile',
},
],
},
];
plugins = [ColumnMoveAdvancedPlugin, RowOddPlugin] as any;
}
The Column Move Advanced plugin is included in the RevoGrid Pro package. To use it, simply import and add it to your grid’s plugins:
import { ColumnMoveAdvancedPlugin } from '@revolist/revogrid-pro';
const grid = document.createElement('revo-grid');grid.plugins = [ColumnMoveAdvancedPlugin];To enable column group dragging:
ColumnMoveAdvancedPlugin to your plugins arrayconst grid = document.createElement('revo-grid');grid.plugins = [ColumnMoveAdvancedPlugin];
// Configure columns with groupsgrid.columns = [ { name: 'Personal Information', children: [ { prop: 'firstName', name: 'First Name' }, { prop: 'lastName', name: 'Last Name' }, { prop: 'age', name: 'Age' }, ], }, { name: 'Address', children: [ { prop: 'street', name: 'Street' }, { prop: 'city', name: 'City' }, { prop: 'country', name: 'Country' }, ], }, { name: 'Contact', children: [ { prop: 'email', name: 'Email' }, { prop: 'phone', name: 'Phone' }, { prop: 'mobile', name: 'Mobile' }, ], },];
// Sample datagrid.source = [ { firstName: 'John', lastName: 'Doe', age: 30, street: '123 Main St', city: 'New York', country: 'USA', phone: '123-456-7890', mobile: '098-765-4321', }, // ... more rows];When you drag a group header:
Important Note
When dragging a group, the plugin ensures that all columns in the group move together. You cannot drag individual columns out of a group using this plugin - the group integrity is maintained throughout the operation.
The plugin emits standard column drag events:
columndragstart: Fired when dragging starts. You can prevent the drag by calling event.preventDefault()beforecolumndragend: Fired before the drag operation completes. You can prevent the move by calling event.preventDefault()columndragend: Fired when the drag operation completesgrid.addEventListener('columndragstart', (event) => { const { data } = event.detail; // Check if dragging a group if (data.children && data.indexes) { console.log('Dragging group:', data.name); }});
grid.addEventListener('columndragend', (event) => { console.log('Drag completed');});The Column Move Advanced plugin makes it easy to reorganize complex data grids with grouped columns while maintaining data structure integrity.