Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82613

How to dynamically set the title of a file.

$
0
0

I have an input field and a print button in a collection dropdown. The input field helps users to set their preferred title dynamically.

Since there are a couple of tables on the page, I was struggling to get the input field's value. But I managed to get it working with below code.

config.parent._collection[0].firstElementChild.value.trim();

Please is it how something like this should be handled or there is a better way?
Thanks.

Test Case: https://live.datatables.net/gidakera/1

The actual code is similar to this.

var table = new DataTable('#example', {
    layout: {
        topStart: {
            buttons: [
                {
                    extend: 'collection',
                    text: 'Export',
                    buttons: [
                        '<input type="text" maxlength="100" placeholder="Enter title">',
                        {
                            extend: 'print',
                            title: function (config, dt) {
                                return config.parent._collection[0].firstElementChild.value.trim();
                            }
                        }
                    ]
                }
            ]
        }
    }
});

Viewing all articles
Browse latest Browse all 82613

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>