Search code examples
htmlcssangularkendo-uitelerik

Angular Kendo - Set Grid Column Width in CSS or SCSS


How do I set the Kendo Grid Column Width in Angular SCSS? The following will set the width in Angular HTML ,

[width]="80"

However, I am trying to transfer style properties from HTML into CSS.

<kendo-grid [data]="propertyViews" [style.height.%]="100"
  [selectable]="false"
  [filterable]="false"
  scrollable="none"
  [height]="350"
  [sortable]="false"
  [pageable]="false"
  [loading]="loadingData">


    <kendo-grid-column field="ownerCombinedname" title="Full Name" [width]="120">
        <ng-template kendoGridCellTemplate let-dataItem let-rowIndex="rowIndex">
            <div>{{dataItem.ownerCombinedname}}</div>
        </ng-template>      
    </kendo-grid-column>
    <kendo-grid-column field="address" title="Mailing Address" [width]="80">
        <ng-template kendoGridCellTemplate let-dataItem let-rowIndex="rowIndex">
            <div>{{dataItem.address}}</div>
        </ng-template>
    </kendo-grid-column>

Proposed Solution:

I tried doing this in SCSS, etc, however it was not working. Seems Kendo is overrunning my CSS style sheet.

td[ng-reflect-logical-col-index="0"] {
    width: 120px;
  }

td[ng-reflect-logical-col-index="1"] {
    width: 80px;
  }

Resources:

https://www.telerik.com/blogs/diving-into-the-kendo-ui-grid-with-angular


Solution

  • Where did you place your css? If it is your component.scss then it might be due to style isolation.

    You need to declare the scss in a global file. Check https://blog.angular-university.io/angular-host-context/

    Let me know if this works for you.