tabalinas / jsgrid

Lightweight Grid jQuery Plugin
http://js-grid.com
MIT License
1.52k stars 352 forks source link

Help selecting columns by name rather than Id #998

Open ghost opened 6 years ago

ghost commented 6 years ago

Hello,

I am in need to select the columns by name instead of id or to retrieve the id of the column using its name and then selecting using the retrieved id.

I am referring to the following function:

grid.fields[_id_of_thecolumn]

I am using this function inside the filterTemplate to dynamically create dropdown options on change.

the grid code works fine if I retrieve the column by id. However there are cases where the user can add optional columns to the grid and this breaks the code (all the id are shifted if the columns are added before the targeted ones).

Thank you for your time.

tabalinas commented 6 years ago

As I understand, by id of the column you mean its index. So could you just grep a column by name then, as it's done internally https://github.com/tabalinas/jsgrid/blob/master/src/jsgrid.core.js#L739?