StrugglingCoder
StrugglingCoder

Reputation: 5011

ui grid columns alignment issue in angular js

In a ui grid in my application there are many columns . But when I try to display them all this what my grid columns look like :

enter image description here

The headers are not there but some how the values are there and it is being a big issue.

The Grid Options I have are ...

this.getGridOption = function (uiScrollOption, BestIndicatorParam, paginationPageSize, enableRowSelection, enableRowHeaderSelection,
    enableSelectAll, enableColumnResize, enableGridMenu, enableFiltering) {


    return {
        enableRowSelection: typeof enableRowSelection !== 'undefined' ? enableRowSelection : false,
        enableRowHeaderSelection: typeof enableRowHeaderSelection !== 'undefined' ? enableRowHeaderSelection : false,
        enableFiltering: typeof enableFiltering !== 'undefined' ? enableFiltering : false,
        enableSelectAll: typeof enableSelectAll !== 'undefined' ? enableSelectAll : false,
        enableColumnResize: typeof enableColumnResize !== 'undefined' ? enableColumnResize : true,
        rowHeight: 55,
        paginationPageSize: typeof paginationPageSize !== 'undefined' ? paginationPageSize : 5,
        paginationPageSizes: [5, 10],
        enablePaginationControls: false,
        enableVerticalScrollbar: 0,
        //enableHorizontalScrollbar: typeof uiScrollOption !== 'undefined' ? uiScrollOption : 0,
        enableHorizontalScrollbar:1,
        enableGridMenu: typeof enableGridMenu !== 'undefined' ? enableGridMenu : true,
        showGridFooter: false,
        columnDefs: this.columnDef,
        data: ''
    }
};

When I show 4-5 columns it is fine , but when I show them all this problem is annoying. What needs to be done. Please help.

Also I need to enable horizontal scroll bar . That's also not working.

I tried to give uiGridConstants.scrollbars.ALWAYS.

But did not work.

Upvotes: 0

Views: 1060

Answers (2)

rameshsriram
rameshsriram

Reputation: 39

Add width for each field in the columns definition with percentage. It will resolve the issue.

[ { name: app.localize('IplNumber'), field: 'id', width: 10% }, 
  { name: app.localize('BrDateReceived'), field:width: 15% }
]

Specify for all of your fields.

Upvotes: 0

Sampath
Sampath

Reputation: 65860

You have to give column width as shown below.

columnDefs: [
                    {
                        name: app.localize('IplNumber'),
                        field: 'id',
                        width: 100,
                    },
                    {
                        name: app.localize('BrDateReceived'),
                        field: 'bpoHeaderPerformedForsOutput[0].dateReceived',
                        width: 140,
                    },
 ],

To enable Horizontal Scroll bar where you have to give it as shown below.

enableHorizontalScrollbar: uiGridConstants.scrollbars.WHEN_NEEDED,

Upvotes: 1

Related Questions