How to implement Button Click Open Search Builder and Search Column hide custom in my code

How to implement Button Click Open Search Builder and Search Column hide custom in my code

jankumar1980jankumar1980 Posts: 6Questions: 2Answers: 0
edited September 2023 in Free community support
$(document).ready(function () {
                var table = $('#Analysis').DataTable({                    
                    lengthChange: true,                  
                    dom: 'lBfrtip',
                    "colvis": [
                        { "searchable": false, "targets": 1 }
                    ],
                    buttons: [
                        'copy',
                        'excel',
                        'csv',                       
                        {
                            text: 'PDF',
                            extend: 'pdfHtml5',
                            action: function (e, dt, node, config) {
                                PrintDiv();
                            }
                        },                      
                    ],
                    searchBuilder: {
                        conditions: {
                            num: {
                                'MultipleOf': {
                                    conditionName: 'Multiple Of',
                                    init: function (that, fn, preDefined = null) {
                                        var el = $('<input/>').on('input', function () { fn(that, this) });
                                        if (preDefined !== null) {
                                            $(el).val(preDefined[0]);
                                        }
                                        return el;
                                    },
                                    inputValue: function (el) {
                                        return $(el[0]).val();
                                    },
                                    isInputValid: function (el, that) {
                                        return $(el[0]).val().length !== 0;
                                    },
                                    search: function (value, comparison) {
                                        return value % comparison === 0;
                                    }
                                }
                            }
                        }
                    }
                });                 
                var buttonContainer = table.buttons().container();
                var searchBuilderContainer = table.searchBuilder.container();
                buttonContainer.insertBefore(table.table().container());
                searchBuilderContainer.insertBefore(table.table().container());                  
            });

Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Answers

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

    How to implement Button Click Open Search Builder and Search Column hide custom in my code

    I'm not sure what you mean. Do you mean putting SearchBuilder into a button? See this example.

    For column visibility see this example (colvis needs to be in your buttons array).

    Allan

  • jankumar1980jankumar1980 Posts: 6Questions: 2Answers: 0

    Already i am try to implement. but not success. please help improve my code

  • jankumar1980jankumar1980 Posts: 6Questions: 2Answers: 0

    i need Search Builder button including buttons: [
    'copy',
    'excel',
    'csv',
    {
    text: 'PDF',
    extend: 'pdfHtml5',
    action: function (e, dt, node, config) {
    PrintDiv();
    }
    },
    ],

Sign In or Register to comment.