Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SlickGrid Columns - Difference between id and field

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

like image 334
Tim Avatar asked Sep 22 '11 13:09

Tim


1 Answers

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 });
like image 94
njr101 Avatar answered Sep 24 '22 05:09

njr101