columnify icon indicating copy to clipboard operation
columnify copied to clipboard

Data Stringified Before dataTransform Option

Open pjobson opened this issue 9 years ago • 1 comments
trafficstars

In this example it returns string in each of the rendered columns, this shows me that the values are pre-stringified before they get to the transform, instead of after which seems more appropriate.

I'd like to do a transform based on the value I passed in rather than a pre-stringified version. If my pre-transformed data is the boolean false, I'd like to be able to test (data===false) or (!data) then do a custom transform. In the existing code false is stringified to "false" so my tests of course fail. I don't want to de-stringify it back to the boolean in case the original value happens to be the the string "false".

Sample code:

var columns = columnify([
    { test: false      },
    { test: new Date() },
    { test: true       },
    { test: 1          },
    { test: 10000      },
    { test: /test/     }
], {
    config: {
        test: {
            dataTransform: function (data) {
                return typeof(data);
            }
        }
    }
});

Renders

TEST
string
string
string
string
string
string

pjobson avatar Apr 14 '16 03:04 pjobson

+1

grinich avatar Oct 17 '18 19:10 grinich