0

The function works fine when calling like this.

                GenColumns({columns: [
                    { headerText: "ID"},
                    { headerText: "Doc"},
                    { headerText: "Customer ID"}
                ] }]

But if I change to this, it doesn’t work.

        var col = [{ headerText: " ID", key: "D"},
            { headerText: "Doc"},
            { headerText: "Customer ID"}
        ];

                GenColumns({columns: [
                    col
                ] })

How can I call function passing a generated string because “col” variable will be generated and does not type manually?

Thanks Wilson

2
  • 2
    GenColumns({columns: col}) Commented Oct 2, 2013 at 7:43
  • 1
    Change GenColumns({columns: [col] }) to GenColumns({columns: col }). col is already an array Commented Oct 2, 2013 at 7:43

3 Answers 3

1

This code

        var col = [{ headerText: " ID", key: "D"},
            { headerText: "Doc"},
            { headerText: "Customer ID"}
        ];

                GenColumns({columns: [
                    col
                ] })

Is not the same as first one ... correct replacement is

        var col = [{ headerText: " ID", key: "D"},
            { headerText: "Doc"},
            { headerText: "Customer ID"}
        ];

                GenColumns({columns: col })

Because you duplicated the arrays. instead of columns : Array( Column ) you made columns : Array( Array( Column ))

Sign up to request clarification or add additional context in comments.

Comments

1

Instead of

GenColumns({columns: [ col ] })

Use

GenColumns({columns: col})

As col is already an array you just need to pass it.

Comments

0
var col = [{ headerText: " ID", key: "D"},
        { headerText: "Doc"},
        { headerText: "Customer ID"}
    ];

            GenColumns({columns: col})

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.