Web Components Adición de filas de cuadrícula

    The Ignite UI for Web Components Row Adding feature in Web Components Grid enables users to input and submit new data records without navigating to a separate form or page. With the IgcGridComponent, users can manipulate data through inline row adding and a powerful API for CRUD operations. Add an IgcActionStrip component with editing actions enabled in the grid's template. After that hover a row and use the provided button. Finally press ALT + + to spawn the row adding UI.

    Web Components Grid Row Adding Example

    Row Adding Usage

    Then define a IgcGridComponent with bound data source, rowEditable set to true and an IgcActionStrip component with editing actions enabled. The addRow input controls the visibility of the button that spawns the row adding UI.

    <igc-grid id="grid" primary-key="ProductID" auto-generate="false" row-editable="true">
        <igc-column field="ProductID" header="Product ID" data-type="Number"></igc-column>
        <igc-column field="ReorderLevel" header="ReorderLever" data-type="Number"></igc-column>
        <igc-column field="ProductName" header="ProductName" data-type="String"></igc-column>
        <igc-column field="UnitsInStock" header="UnitsInStock" data-type="Number"></igc-column>
        <igc-column field="OrderDate" data-type="Date"></igc-column>
        <igc-column field="Discontinued" header="Discontinued" data-type="Boolean"></igc-column>
    
        <igc-action-strip id="actionstrip">
            <igc-grid-editing-actions add-row="true"></igc-grid-editing-actions>
        </igc-action-strip>
    </igc-grid>
    

    Nota: La configuración de la clave principal es obligatoria para las operaciones de adición de filas.

    Note: Every column excluding the primary key one is editable in the row adding UI by default. If you want to disable editing for a specific column, then you have to set the editable column's input to false.

    Note: The IgcGridEditingActions input controlling the visibility of the add row button may use the action strip context (which is of type IgcRowType to fine tune which records the button shows for.

    The internal BaseTransactionService is automatically provided for grid. It holds pending cell changes until the row state is submitted or cancelled.

    Start Row Adding Programmatically

    grid allows to programmatically spawn the add row UI by using two different public methods. One that accepts a row ID for specifying the row under which the UI should spawn and another that works by index. You can use these methods to spawn the UI anywhere within the current data view. Changing the page or specifying a row that is e.g. filtered out is not supported.

    Using beginAddRowById requires you to specify the row to use as context for the operation by its RowID (PK). The method then functions as though the end-user clicked on the add row action strip button for the specified row, spawning the UI under it. You can also make the UI spawn as the very first row in the grid by passing null for the first parameter.

    this.grid.beginAddRowById('ALFKI');  // Spawns the add row UI under the row with PK 'ALFKI'
    this.grid.beginAddRowById(null);     // Spawns the add row UI as the first record
    

    The beginAddRowByIndex method works similarly but requires you to specify the index at which the UI should spawn. Allowed values range between 0 and the size of the data view - 1.

    this.grid.beginAddRowByIndex(10);   // Spawns the add row UI at index 10
    this.grid.beginAddRowByIndex(0);    // Spawns the add row UI as the first record
    

    Positioning

    • La posición predeterminada de la interfaz de usuario para agregar filas está debajo de la fila en la que el usuario final hizo clic en el botón Agregar fila.

    • The grid scrolls to fully display the add row UI automatically.

    • La superposición de la interfaz de usuario para agregar fila mantiene su posición durante el desplazamiento.

    Behavior

    La interfaz de usuario para agregar filas tiene el mismo comportamiento que la de edición de filas, ya que están diseñadas para brindar una experiencia de edición consistente a los usuarios finales. Consulte el tema Edición de filas de cuadrícula para obtener más información.

    After a new row is added through the row adding UI, its position and/or visibility is determined by the sorting, filtering and grouping state of the grid. In a grid that does not have any of these states applied, it appears as the last record. A snackbar is briefly displayed containing a button the end user may use to scroll the grid to its position if it is not in view.

    Keyboard Navigation

    • ALT + +: ingresa al modo de edición para agregar una fila
    • ESC sale del modo de agregar filas sin enviar ningún cambio

    • TAB mueve el foco de una celda editable en la fila a la siguiente y de la celda editable más a la derecha a los botones CANCELAR y LISTO. La navegación desde el botón LISTO va a la celda editable más a la izquierda dentro de la fila actualmente editada.

    Feature Integration

    • Any row adding operation will stop if the data view of the grid gets modified. Any changes made by the end user are submitted. Operations that change the data view include but are not limited to sorting, grouping, filtering, paging, etc.

    • Los resúmenes se actualizan una vez finalizada la operación de agregar filas. Lo mismo es válido para otras funciones dependientes de la vista de datos, como ordenar, filtrar, etc.

    Customizing Row Adding Overlay

    Customizing Text

    Customizing the text of the row adding overlay is possible using the rowAddTextTemplate.

    this.grid.rowAddTextTemplate = (ctx: IgcGridEmptyTemplateContext) => {
        return html`Adding Row`;
    }
    

    Styling

    The row adding UI comprises the buttons in the IgcActionStrip editing actions, the editing editors and overlay, as well as the snackbar which allows end users to scroll to the newly added row. To style these components you may refer to these comprehensive guides in their respective topics:

    API References

    Additional Resources

    Nuestra comunidad es activa y siempre da la bienvenida a nuevas ideas.