Template background not covered in Kendo for Angular grid
NickName:ps0604 Ask DateTime:2018-12-02T19:52:09

Template background not covered in Kendo for Angular grid

In this StackBlitz I have a Kendo for Angular grid with cell templates. The background color doesn't cover the entire cell, how to make it cover? Note that if I increase the span font size from 9px to 12px, the background is expanded but I need it to work even with small fonts.

@Component({
   selector: 'my-app',
   encapsulation: ViewEncapsulation.None,
   styles: [`
      .k-grid .no-padding {
        padding: 0;
      }
       .whole-cell {
         display: block;
         width: 100%;
         height: 100%;
         padding: 8px 12px; /* depends on theme */
       }
   `],
   template: `
       <kendo-grid [data]="gridData">
         <kendo-grid-column field="ProductName" title="Product Name">
         </kendo-grid-column>
         <kendo-grid-column field="UnitPrice" title="Unit Price" width="230">
         </kendo-grid-column>
         <kendo-grid-column field="code" title="Code" width="230" class="no-padding">
            <ng-template kendoGridCellTemplate let-dataItem>
              <span class="whole-cell" 
              style="font-size: 9px;"
              [style.backgroundColor]="colorCode(dataItem.code)">
                {{ dataItem.code }}
              </span>
            </ng-template>
         </kendo-grid-column>
       </kendo-grid>
   `
})
export class AppComponent {
   public gridData: any[] = products;

   constructor(private sanitizer: DomSanitizer) {}

   public colorCode(code: string): SafeStyle {
     let result;

     switch (code) {
      case 'C1' :
        result = '#FFBA80';
        break;
      case 'C2' :
        result = '#B2F699';
        break;
      default:
        result = 'transparent';
        break;
     }

     return this.sanitizer.bypassSecurityTrustStyle(result);
   }
}

Copyright Notice:Content Author:「ps0604」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/53579944/template-background-not-covered-in-kendo-for-angular-grid

More about “Template background not covered in Kendo for Angular grid” related questions

Template background not covered in Kendo for Angular grid

In this StackBlitz I have a Kendo for Angular grid with cell templates. The background color doesn't cover the entire cell, how to make it cover? Note that if I increase the span font size from 9px...

Show Detail

Using Angular template for Kendo UI Grid detail template

I am using the Kendo UI package for Angular JS. I would like to use an Angular template for the row detail, very similar to what is done here: Kendo Grid Detail Template Essentially I would like to

Show Detail

Kendo-Angular : How to create kendo grid with template on columns?

How to create kendo grid with Kendo-Angular with export: I have kendo grid with columns. The columns have template. When I export grid to excel file the columns with template doesn't show &lt;kend...

Show Detail

Kendo angular UI : kendo grid cell selection/highlight

I want to select/highlight kendo grid's cell on selection.When I right click on cell a context menu gets display which is individual for each cell. Please find my work progress here https://stackbl...

Show Detail

Kendo for Angular Grid with tooltip

I am looking for a example for using kendo-grid Kendo for angular Grid for angular with tooltip on all cells and header. I found they have this tooltip EDIT!!!! I need to put in the template a f...

Show Detail

Angular Kendo Grid

I use Kendo UI for Angular. In the kendo grid I have a problem: When I add a new record in the grid show 'valueField' instead textField. How can I change that and set editable mode when new record

Show Detail

Unit test an Angular-Kendo Grid Datasource - all code paths

I'm writing custom Angular directives for a new application and unit testing them using Jasmine. However, I can't for the life of me figure out how to get full code coverage (or even 80%) on the Ke...

Show Detail

Footer for kendo-grid Angular

Need help in finding footer sum of kendo-grid angular. &lt;kendo-grid [data]="gridData"&gt; &lt;ng-template ngFor [ngForOf]="columns" let-column&gt; &lt;kendo-grid-column field="{{co

Show Detail

Kendo UI Grid style cell based on template-value

I would like to set the cellStyle of a specific cell based on its value. If Status == STARTED, i want the background to be green. If Status == STOPPED, i want the background to be red. consider...

Show Detail

Grid with angular-kendo-ui grid with requirejs

I am trying to use "kendo.grid.min" with angular and requireJs. In the require.config I defined this: paths: { ... kendouiGrid: '../bower_components/kendo-ui/js/kendo.grid.min',

Show Detail