Modify display controller to view only specific fields

Modify display controller to view only specific fields

ianbrunetianbrunet Posts: 14Questions: 2Answers: 0

Hi!

When I create a row, I upload several files (https://editor.datatables.net/examples/advanced/upload-many.html).
I would like to view the attached files corresponding to a row by clicking on the left button (in green in the example) from https://editor.datatables.net/examples/plug-ins/displayController.html. The example works perfectly but I would like to hide the other fields and only show the links to the attached files.

I know that I have to modify the first parameter from editor.edit in :

$('#example').on('click', 'td.details-control', function () {
                var tr = this.parentNode
          
                if ( table.row( tr ).child.isShown() ) {
                    editor.close();
                }
                else {
                    editor.display
                    editor.edit(
                        tr,
                        'Pièces jointes',
                        [
                            {
                                "className": "delete",
                                "label": "Delete row",
                                "fn": function () {
                                    // Close the edit display and delete the row immediately
                                    editor.close();
                                    editor.remove( tr, '', null, false );
                                    editor.submit();
                                }
                            }, {
                                "label": "Update row",
                                "fn": function () {
                                    editor.submit();
                                }
                            }
                        ]
                    );
                }
            });

I tried several things (replace tr by #row_2 or the name of the documents fields) but it does not work... How can I do this?

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin

    It sounds like you don't actually want the information in the child row to be editable - but rather just to display the links. Is that correct?

    If so, son't use the Editor example for the child rows you linked to - that is specifically for making the Editor form display in the child rows!

    Instead, have a look at this example which shows how to create a child row with any data you want in it.

    Allan

  • ianbrunetianbrunet Posts: 14Questions: 2Answers: 0

    Thank you very much! This is exactly what I wanted.

This discussion has been closed.