Complex Formatting Question -

Complex Formatting Question -

danielsandanielsan Posts: 2Questions: 1Answers: 0
edited August 2017 in Free community support

Apologize if this has been asked, I searched using the best keywords I could think of, but I cannot find any solution or anything to get me in the right direction.

first time using DT and I love the concept and apparent simplicity in this! You guys nailed it.... but this one table I'm trying to build it giving me fits.

Attached is a screen of a table I'm trying to replicate. Also attached is my data as I have it currently formatted for this table.

I'd like my columns to be periods (MM/YYYY).
I'd like my rows to be statistical groups. Ideally with a TH on the row as shown (I kinda got this, but it's creating sortable column above the column, I'd rather not have)

I'm having a very hard time formatting my data to get into a DT like this and/or to configure the DT to display data liek this.

First question, is it possible to have variable column names? In my case, it is going to span a date range as defined by the user, so it might be simply "2017-01", "2017-02" and "2017-3" but it almost might be every month for 2 years.

Any tips on how I might be able to format this correctly? I'd love to use this but I've been stumped for about 7 hours trying to get anything to work, and I cannot.

Also I am passing in Columns that match the data that looks like this:
table_columns = [
data: "2017-01",
data: "2017-02",
etc
}

Call to render DT is:

$( '#historical-data' ).DataTable({
data: table_data,
columns: table_columns
});

Answers

  • danielsandanielsan Posts: 2Questions: 1Answers: 0

    UPDATE: I got one step closer.
    I was passing in table_data like this:

    table_data = {
    "arpu" : [ 2017-01: 100, 2017-02: 125, ......],
    "ltv" : [ 2017-01: 300, 2017-02: 499, ....]
    };

    I changed to this:
    table_data = [
    [ 20170101: 100, 20170201: 125], .....],
    [ 20170101: 300, 20170201: 499, ......]
    };

    table_columns = [
    data: "20170101",
    data: "20170201"
    ]

    and now at least the data populates the table, but headers are stil not showing

This discussion has been closed.