web component - How to sort the columns in the tool panel. Ag-Grid -
edit: found out move column doesn't work in v6.4.0
example link: https://www.ag-grid.com/javascript-grid-tool-panel/toolpanelexample.html
the order of columns visible in tool panel in same order defined in column definition. check image below.
is possible sort them in tool panel in order(say alphabetically) without changing order shown in grid.
what tried:
i tried defining them in alphabetical order in columndefination , tried move them there position using columnapi.movecolumn()
. doesn't seems work either increases complexity when have move columns , position them.
questions:
- is possible/feasible?
- the
movecolumn()
function not working. can tell in version introduced not able find in changelog.
additional details:
using ag-grid enterprise version v6.4.0
please refer this plnkr. used same basic idea had, creating coldefs in alphabetical order in ongridready function moved columns respective placements. there 2 functions useful in doing this, second preferable in opinion:
movecolumn(colkey, toindex) //colkey refers id of column defaults specified field //toindex number within range of columns. movecolumns(colkeys[], toindex) //colkeys[] array in order want them displayed starting @ toindex
here how implemented in plnkr:
private onready() { // this.gridoptions.columnapi.movecolumn('name',1) // this.gridoptions.columnapi.movecolumn('country',2) // this.gridoptions.columnapi.movecolumn('dob',3) // this.gridoptions.columnapi.movecolumn('skills',4) // this.gridoptions.columnapi.movecolumn('proficiency',5) // this.gridoptions.columnapi.movecolumn('mobile',6) // this.gridoptions.columnapi.movecolumn('landline',7) // this.gridoptions.columnapi.movecolumn('address',8), this.gridoptions.columnapi.movecolumns(['name', 'country', 'dob', 'skills', 'proficiency', 'mobile', 'landline', 'address'],1) }
there 1 more function available if use it:
movecolumnbyindex(fromindex, toindex) //this uses indexes , not colid/colkey idea if prefer keep more anonymous
Comments
Post a Comment