Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to turn off ui-grid column header formatting

so, I have this column definition for my ui-grid

columnDefs: [
        { name: 'Usr#', field: 'userNum', width: '*', resizable: true},         
        { name: 'Name', field: 'userName', width: '*', resizable: true},            
        { name: 'PID', field: 'userPID', width: '*', resizable: true},          
        { name: 'Flags', field: 'userFlags', width: '*', resizable: true},          
        { name: 'Blk Acc', field: 'dbAccess', width: '*', resizable: true},         
        { name: 'OS Rd', field: 'osReads', width: '*', resizable: true},            
        { name: 'OS Wr', field: 'osWrites', width: '*', resizable: true},           
        { name: 'Hit%', field: 'hitRatio', width: '*', resizable: true},            
        { name: 'Rec Lck', field: 'recLks', width: '*', resizable: true},           
        { name: 'Rec Wts', field: 'recWts', width: '*', resizable: true},           
        { name: 'Line#', field: 'lineNum', width: '*', resizable: true},            
        { name: 'Program Name', field: 'procName', width: '*', resizable: true},            
    ]

and I have this grid :

enter image description here

ui-grid is being friendly and trying to format the column headers for me - but I don't want it to ;)

how can / do I turn this option off ?

Also, is it possible to set a column to auto-fit the width of the largest data item ?

like image 603
jmls Avatar asked Nov 20 '25 00:11

jmls


1 Answers

A workaround to no have your header reformatted is to use the displayName field: For instance:

columnDefs: [
...
        { name: 'PID', displayName: 'PID', field: 'userPID', width: '*', resizable: true}, 
...
like image 62
Frederic Dang Ngoc Avatar answered Nov 24 '25 15:11

Frederic Dang Ngoc