0

I am trying to dynamically send a list object (as below) in JavaScript.

I am trying to setup a dynamic grid which accepts dynamic column names (instead of hardcoding the columns)

I am trying to create columnmap dynamically that will be used by grid, something like below,

columMap : {
    'Header' : [
        { title : "Title", field : "Title" },
        { title : "Created", field : "Created" },
        { title : "Created By", field : "CreatedBy.Account" }
    ]

I tried with var list={field : 'Name',title:'Name'}.. This works fine for one column but does't work for multiple columns. I tried array too, didn't work.. Anyone has any suggestions?

3
  • 2
    Have you tried this -> var list = [{field : 'Name',title:'Name'}, {field : 'Name1',title:'Name1'}] Is this something of structure that you are looking for? Commented Oct 18, 2012 at 21:52
  • How exactly did you "try array?" Commented Oct 18, 2012 at 21:53
  • Send an object/array where/how/when? Please be more specific. Maybe the MDN JavaScript Guide helps you: developer.mozilla.org/en-US/docs/JavaScript/Guide/…. Commented Oct 18, 2012 at 21:54

2 Answers 2

3

[] represents an empty array

[1, 2, 3] is an array of three numbers

[ { a: 1 }, { a: 1 } ] is an array of objects

[ 1, "a", { a: 3 } ] an array does not care what type it holds

So...

var list = 
[
    {field : 'Name',title:'Name'}
];
Sign up to request clarification or add additional context in comments.

Comments

0

Sorry, it was my mistake... I forgot to remove [] when I was passing my list object hence it was not able to set the value..

I got it resolved by passing list as below..

var list = [{ field: 'Name',title: 'Name' },{ field:'ContextNamePathRaw',title: 'Ownership Hierarchy'} ];

Thanks for your help!!!

BB

Comments

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.