10

A simple question i cant workout. In a column definition whats the difference between the field property and the id property...Fx..

columns.push({ id: "officeId", name: "Office Id", field: "officeId", width: 40 });

When would they be different/why two?

Thanks? Tim

VividD
  • 10,456
  • 6
  • 64
  • 111
Tim
  • 3,576
  • 6
  • 44
  • 58
  • I think i figured this out. Seems like the id is the id to reference the column while the field is the data field in the dataset. – Tim Sep 22 '11 at 18:33

1 Answers1

7

The id is just a unique identifier for the column. You can set it to anything you want. It's only use is to provide an identifier when you want to refer to your columns from code.

The field specifies how the column binds to the underlying data. Suppose your data looks like this:

data = [ 
         { firstName: "John", lastName: "Smith" },
         { firstName: "Fred", lastName: "Jones" }
       ];

When you define the column you can tell it which value you want to display from your data array.

columns.push({ id: "anythingyoulike", name: "Surname", field: "lastName", width: 40 });
njr101
  • 9,499
  • 7
  • 39
  • 56
  • 1
    Yes. In other words, `id` allows you to define two columns with the same name, which will handle equally named data. – deprecated Oct 30 '11 at 10:45