Base solution for your next web application
Open Closed

Centrlize the content of a grid cell #1233


User avatar
0
inovatech created

I would like to centralize the contents of a grid cell, but I can't. In SurName column on columnDefs, I tried to use cellClass, but did not work (file \App\common\views\users\index.js). Could help me, please?


1 Answer(s)
  • User Avatar
    0
    hikalkan created
    Support Team

    Hi,

    Have you checked angular ui-grid's document for this: <a class="postlink" href="http://ui-grid.info/">http://ui-grid.info/</a>

    In addition, if you check js code, you will see we made customizations for some columns. Example: IsActive column:

    {
                            name: app.localize('Active'),
                            field: 'isActive',
                            cellTemplate:
                                '<div class=\"ui-grid-cell-contents\">' +
                                '  <span ng-show="row.entity.isActive" class="label label-success">' + app.localize('Yes') + '</span>' +
                                '  <span ng-show="!row.entity.isActive" class="label label-default">' + app.localize('No') + '</span>' +
                                '</div>',
                            minWidth: 80
                        },
    

    To make this centralized, just add text-center class to 'ui-grid-cell-contents' div. Example:

    {
                            name: app.localize('Active'),
                            field: 'isActive',
                            cellTemplate:
                                '<div class=\"ui-grid-cell-contents text-center\">' +
                                '  <span ng-show="row.entity.isActive" class="label label-success">' + app.localize('Yes') + '</span>' +
                                '  <span ng-show="!row.entity.isActive" class="label label-default">' + app.localize('No') + '</span>' +
                                '</div>',
                            minWidth: 80
                        },