Descripción general de los encabezados de varias columnas React Tree Grid
La función Ignite UI for React Cabeceras Multicolumna en React Tree Grid permite agrupar columnas colocándolas bajo un encabezado múltiple común. Cada grupo de cabeceras de varias columnas en elIgrTreeGrid podría ser una representación de combinaciones entre otros grupos o columnas. Esta función es especialmente útil al tratar con grandes conjuntos de datos donde desplazarse horizontalmente puede resultar engorroso.
React Tree Grid Multi-Column Headers Example
La declaración de cabeceras de varias columnas se consigue envolviendo un conjunto de columnas en uncolumnGroup componente conheader la información del título pasada.
<IgrTreeGrid primaryKey="ID" foreignKey="ParentID">
<IgrColumnGroup header="Contact Information">
<IgrColumn sortable={true} resizable={true} field="Phone" dataType="string"></IgrColumn>
<IgrColumn sortable={true} resizable={true} field="Fax" dataType="string"></IgrColumn>
<IgrColumn sortable={true} resizable={true} field="PostalCode" dataType="string"></IgrColumn>
</IgrColumnGroup>
</IgrTreeGrid>
Para alcanzarn-th el nivel de encabezados anidados, debe seguirse la declaración anterior. Así que anidarcolumnGroup conduce al resultado deseado.
<IgrTreeGrid primaryKey="ID" foreignKey="ParentID" moving={true}>
<IgrColumnGroup pinned={false} header="General Information">
<IgrColumn field="HireDate" sortable={true} resizable={true} dataType="date"></IgrColumn>
<IgrColumnGroup header="Person Details">
<IgrColumn field="ID" resizable={true} filterable={true} dataType="number"></IgrColumn>
<IgrColumn field="Title" sortable={true} resizable={true} dataType="string"></IgrColumn>
<IgrColumn field="Age" sortable={true} resizable={true} dataType="number"></IgrColumn>
</IgrColumnGroup>
</IgrColumnGroup>
</IgrTreeGrid>
TodoscolumnGroup apoyan moverse, inmovilizar y esconderse.
[!Note] When there is a set of columns and column groups, pinning works only for top level column parents. More specifically pinning per nested column groups or columns is not allowed.
Moving between columns and column groups is allowed only when they are at the same level in the hierarchy and both are in the samegroup.
Whencolumns/column-groupsare not wrapped by currentgroupwhich means they are top levelcolumns, moving is allowed between whole visible columns.
<IgrTreeGrid primaryKey="ID" foreignKey="ParentID" moving={true}>
<IgrColumnGroup header="Contact Information">
<IgrColumn field="Phone" movable={true} sortable={true} resizable={true} dataType="string"></IgrColumn>
</IgrColumnGroup>
<IgrColumn field="Name" sortable={true} resizable={true} dataType="string"></IgrColumn>
<IgrColumn field="Title" sortable={true} resizable={true} dataType="string"></IgrColumn>
<IgrColumn field="Age" sortable={true} resizable={true} dataType="number"></IgrColumn>
</IgrTreeGrid>
Multi-Column Header Template
<IgrColumnGroup header="Contact Information" headerTemplate={groupHeaderTemplate}></IgrColumnGroup>
const groupHeaderTemplate = (e: IgrColumnTemplateContext) => {
const column = e.column as IgrColumnGroup;
return (
<div>
<span style={{ float: "left" }}>{column.header.toUpperCase()}</span>
</div>
);
}
[!Note] If a header is re-templated and the corresponding column group is movable, you have to set the draggable attribute to false on the templated elements, so that you can handle any of the events that are applied!
const columnHeaderTemplate = (e: IgrColumnTemplateContext ) => {
const column = e.column as IgrColumnGroup;
return (
<span onClick={onClick}>
<IgrIcon data-draggable="false"></IgrIcon>
</span>
);
}
El siguiente ejemplo demuestra cómo implementar grupos de columnas contraíbles utilizando plantillas de encabezado.
Styling
Además de los temas predefinidos, la cuadrícula se puede personalizar aún más configurando algunas de las propiedades CSS disponibles. En caso de que desee cambiar algunos de los colores, primero debe establecer una clase para la cuadrícula:
<IgrTreeGrid className="grid"></IgrTreeGrid>
Luego establezca las propiedades CSS relacionadas con esta clase:
.grid {
--ig-grid-header-background: #e0f3ff;
--ig-grid-header-text-color: #e41c77;
--ig-grid-header-border-width: 1px;
--ig-grid-header-border-style: solid;
--ig-grid-header-border-color: rgba(0, 0, 0, 0.08);
}
Demo
API References
Additional Resources
Nuestra comunidad es activa y siempre da la bienvenida a nuevas ideas.