Non repeating first TD cell in editor.

Non repeating first TD cell in editor.

webpointzwebpointz Posts: 126Questions: 30Answers: 4

I have an editor table that shows order details from an orderdetails table (multiple entries for an order).

The first cell of the table is the order number and instead of repeating the same ordernumber on every line I want to show it for the first iteration but show a blank cell for any other rows that follow.

Is there a way to accomplish this with Editor?

Thanks

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Answer ✓

    Not with Editor as this is DataTables specific and not editing - but you could potentially use a draw event to loop over the displayed rows and remove / update the HTML displayed.

    A similar technique is used in the row grouping example.

    Allan

  • webpointzwebpointz Posts: 126Questions: 30Answers: 4

    Thanks

    In the editor JS file I added the following and hid the first cell and it works great:

    "drawCallback": function ( settings ) {
                var api = this.api();
                var rows = api.rows( {page:'current'} ).nodes();
                var last=null;
     
                api.column(0, {page:'current'} ).data().each( function ( group, i ) {
                    if ( last !== group ) {
                        $(rows).eq( i ).before(
                            '<tr class="group" style="font-weight:bold;background:#ccc;"><td colspan="8">'+group+'</td></tr>'
                        );
     
                        last = group;
                    }
                } );
            }
    
This discussion has been closed.