Use of render() and createdCell() functions along with bubble editing in client-side processing

Use of render() and createdCell() functions along with bubble editing in client-side processing

ISYCISYC Posts: 2Questions: 1Answers: 0

Hi,

We're starting to use Editor in our tables (bubble editing). Typically, the configuration of the columns looks like this (in this case, only the columns "name" and "codename" are editable):

{
    columns: [
            {
                data: 'timestamp',
                visible: false,
                orderable: false,
                searchable: false
            },
            {
                data: 'id',
                orderable: false,
                searchable: false,
                width: "42px",
                render: function ( data, type, row, meta ) {
                    // Some code that renders buttons/icons
                },
                createdCell: function (td, cellData, rowData, row, col) {
                    // Some code that assigns click events to the rendered buttons/icons, sometimes based on the data of the row
                }
            },
            {
                data: 'name',
            },
            {
                data: 'codename',
            },
            ...
    ],
    ...
}

This schema is functioning well when we use server-side processing (serverSide: true): every time I modify one of the cells, the table is redrawn and both methods (render and createdCell) are called. However, if we use client-side processing, only the render function is called. How can we achieve the rendering and the click events using this approach on both server-side and client-side processing?

Thanks,

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    Answer ✓

    The columns.createdCell method is triggered only when the cell is actually created. With client-side processing, that happens only once since we reuse the cell.

    If you are just using columns.createdCell to add events, I'd suggest instead that you use a delegated event such as that shown here which will make life much easier!

    Allan

  • ISYCISYC Posts: 2Questions: 1Answers: 0

    Thanks Allan! We'll try to use delegated events, as it works properly on both scenarios.

Sign In or Register to comment.