1

I've been trying to figure out this particular object for quite a while and it's frustrating me endlessly so I was hoping to get it resolved here.

I have an object that looks like this:

options = {
    headers: {
        rows: [
            cols = {
                text: "Blah",
                span: 12,
                color: "#FFF"
            }
        ],
        [
            cols = {
                text: "Blah2",
                span: 8,
                color: "#FFF"
            }
            cols = {
                text: "Blah2",
                span: 4,
                color: "#FFF"
            }
        ]
    }
}

With the intended result being an object that can be used to populate header rows above a table using a combination of the text, span, and color properties (with a few additions for later) to customize styling it properly.

I'm going for:

var text = options.headers.rows[x].cols[y].text;

Such that a nested loop can generate out the headers. Any help is appreciated!

1
  • Mmh, you have an error in your object, {headers: {rows: [...], <here> [...]}} are you missing a property name here? Commented Jul 8, 2010 at 15:38

1 Answer 1

4

[See it in action]

var options = {
    headers: {
        rows: [ // Array
        { // row: 0
            cols: [ // Array
            { // col: 0
                text: "Blah",
                span: 12,
                color: "#FFF"
            },
            { // col: 1
                text: "Blah2",
                span: 8,
                color: "#FFF"
            },
            { // col: 2
                text: "Blah2",
                span: 4,
                color: "#FFF"
            }]
        },
        { // row: 1
            cols: [ // Array
            { // col: 0
                text: "Blah",
                span: 12,
                color: "#FFF"
            },
            { // col: 1
                text: "Blah2",
                span: 4,
                color: "#FFF"
            }]
        }]
    }
};
Sign up to request clarification or add additional context in comments.

1 Comment

Awesome! Thanks, I am going to add the comments from the source view of that jsbin so that I can understand what was done here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.