Help Customizing listHidden Function

Help Customizing listHidden Function

TomHallTomHall Posts: 27Questions: 10Answers: 1
edited September 9 in Free community support

I am hoping to customize the listHidden function in that instead of it going column by column,and returning an <li> for each hidden column in a responsive table, I want to combine the values of some columns. For example instead of

<li>My Date</li>
<li>My Time</li>
<li>My City</li>
<li>My State</li>

I want to have

<li>My Date & My Time</li>
<li>My City & My State</li>

I have been playing with the function and thought to have a switch statement before the return col.hidden ? but I don't think that will work.

    listHidden: function () {
        return function (api, rowIdx, columns) {
            var data = $.map(columns, function (col) {
                var klass = col.className ?
                    'class="' + col.className + '"' :
                    '';


                switch (col.title) {
                    case "Date":
                        Date & Time Here
                    case "City":
                        City & State Here
                        break;
                }
                    return col.hidden ?
                        '<li ' + klass + ' data-dtr-index="' + col.columnIndex + '" data-dt-row="' + col.rowIndex + '" data-dt-column="' + col.columnIndex + '">' +
                        '<span class="dtr-data">'  + col.data +  '</span>' +
                        '</li>' :
                        '';
            }).join('');

            return data ?
                $('<ul data-dtr-index="' + rowIdx + '" class="dtr-details" " style="display:flex;"/>').append(data) :
                false;
        };
    },

Answers

  • TomHallTomHall Posts: 27Questions: 10Answers: 1

    What challenges me is that this function is focused on one column at a time, so to get Date & Time, I would have to get the value from another column in addition to current one

  • colincolin Posts: 9,822Questions: 0Answers: 1,629

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

Sign In or Register to comment.