How to customize ngx-datatable css for rows - html

I try to apply some css for the ngx-datatable element like this.
.datatable-body-row:hover {
background-color: #3387b5;
}
Nothing changed, result are the same. The css remains default setting.
The color is still the same when I hover my mouse to the specific row.
How can I customize it? Thankyou.
For reference the over all HTML structure are like this.
<ngx-datatable >
<!-- row are included in these column, but these column includes header-->
<ngx-datatable-column >
<ng-template ngx-datatable-header-template>
<label class="datatable-checkbox">
<input />
</label>
</ng-template>
<ng-template ngx-datatable-cell-template >
<label class="datatable-checkbox">
<input type="checkbox" />
</label>
</ng-template>
</ngx-datatable-column>
<ngx-datatable-column *ngFor="let column of columns; let i = index" >
</ngx-datatable-column>
</ngx-datatable>

Probably lower CSS Priority
you can use this or raise Priority other way https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity
.datatable-body-row:hover,
.datatable-body-row:hover .datatable-row-group {
background-color: #3387b5 !important;
}

Related

PrimeNG Angular 10 - How to add an icon in p-autoComplete

Is there a way to add an icon inside primeng p-autoComplete?
<div class="p-mr-2 p-input">
<p-autoComplete styleClass="p-autocomplete-list-item" [(ngModel)]="location"
[suggestions]="results" field="name" placeholder="Search location">
</p-autoComplete>
</div>
I am looking for a way to add a location icon inside this auto-complete element
PrimeNg provides InputGroup option which can be used to add icon for input.
<div class="p-mr-2 p-input">
<div class="p-inputgroup">
<span class="p-inputgroup-addon">$</span>
<p-autoComplete styleClass="p-autocomplete-list-item" [(ngModel)]="location [suggestions]="results" field="name" placeholder="Search location">
</p-autoComplete>
</div>
</div>
Here instead of $ add required location icon.
there is a Property "dropdownIcon" takes the name of an icon the default
"pi pi-chevron-down".
<p-autoComplete
[group]="true"
field="label"
[multiple]="true"
[dropdown]="true"
dropdownIcon="pi pi-search"
>

How to disable kendo-grid-checkbox-column?

How to disable kendo-grid-checkbox-column?
I have tried
[disabled]="true"
[attr.disabled]="true"
disabled ="true"
disabled
readonly
But nothing is helped to disable this below column
<kendo-grid-checkbox-column width="50" showSelectAll="true">
</kendo-grid-checkbox-column>
You can produce a disabled checkbox by specifying custom templates and adding a condition to the [disabled] attribute.
<kendo-grid-checkbox-column width="80" [locked]="true">
<ng-template kendoGridCellTemplate let-dataItem let-rowIndex="rowIndex" >
<input *ngIf="!dataItem.IsNew"
[disabled]="dataItem.IsNew === true"
type="checkbox"
class="k-checkbox"
id="checkbox-{{rowIndex}}"
[kendoGridSelectionCheckbox]="rowIndex"
/>
<label class="k-checkbox-label"
for="checkbox-{{rowIndex}}">
</label>
</ng-template>
</kendo-grid-checkbox-column>
This will render out a Kendo checkbox that will be disabled according to your conditions specified above.
If you want to display a select all checkbox in the header you need to add this template to the checkbox column:
<ng-template kendoGridHeaderTemplate >
<input kendoGridSelectAllCheckbox type="checkbox"
class="k-checkbox"
id="headerCheckbox"
/>
<label class="k-checkbox-label"
for="headerCheckbox"
></label>
</ng-template>
You can use the Grid rowClass input and provide a function that will return the "k-disabled" class (or any other custom class that would prevent the user from interacting with the given row), for all data items that pass some condition, e.g.:
public isDisabled(args) {
return {
'k-disabled': args.dataItem.UnitsOnOrder === 0
};
}
I hope this helps.
========OR========
<kendo-grid-checkbox-column>
<ng-template kendoGridCellTemplate let-dataItem let-
rowIndex="rowIndex" >
<div class="{{dataItem.UnitsOnOrder === 0 ? 'k-disabled' : ''}}">
<input [kendoGridSelectionCheckbox]="rowIndex" />
</div>
</ng-template>
CSS class was changed from k-disabled to k-state-disabled in recent Kendo UI theme versions
Resource: https://www.telerik.com/forums/kendo-angular-grid---row-selection

ngx-datatable column header tooltip gets cut off

<ngx-datatable-column [width]="24"
[sortable]="true"
[canAutoResize]="false"
[draggable]="false"
[resizeable]="false"
[headerCheckboxable]="true"
[checkboxable]="true">
</ngx-datatable-column>
<ngx-datatable-column name='Name' prop='formattedStudentName' [width]="400" [cellClass]="'se-list-item'">
<ng-template let-column="column" ngx-datatable-header-template>
<ng-container>
<div ngbTooltip="Click on the word 'Name' to change the sort direction of the student list">
{{column.name}}
</div>
</ng-container>
</ng-template>
<ng-template let-value="value" let-row="row" ngx-datatable-cell-template>
<div>
{{value}}
</div>
</ng-template>
</ngx-datatable-column>
This is part of my code. I needed to use a ngbTooltip, which works, for the column header, but when I hover the bubble gets cut off by the datatable. How can I prevent it from getting cutoff?
<ngx-datatable-column name='Name' prop='formattedStudentName' [width]="400" [cellClass]="'se-list-item'">
<ng-template let-column="column" ngx-datatable-header-template>
<ng-container>
<div container="body" ngbTooltip="Click on the word 'Name' to change the sort
direction of the student list">
{{column.name}}
</div>
</ng-container>
</ng-template>
<ng-template let-value="value" let-row="row" ngx-datatable-cell-template>
<div>
{{value}}
</div>
</ng-template>
</ngx-datatable-column>
By adding container="body" to the div with the tooltip it allowed the tooltip window to pop over the borders of the ngx-datatable.
Side note: in my research I found that for ngbTooltip you can add tooltipClass="className" to customize the tooltip window.

ng-select multi select checkbox with reactive forms in angular 6

Please go through the link(https://ng-select.github.io/ng-select#/multiselect-checkbox) to know ng-select multi select checkbox.
I am trying to use the ng-select "Group selects children" in my angular 6 application.
I am having problem using ng-select "Group selects children" with Reactive Forms instead of template driven forms.
I have tired it as
<ng-select
[items]="userGroupsList"
[multiple]="true"
bindLabel="name"
groupBy="gender"
[selectableGroup]="true"
[selectableGroupAsModel]="false"
[closeOnSelect]="false"
bindValue="id"
formControlName="userGroups" placeholder="Select a user group">
<ng-template ng-optgroup-tmp let-item="item" let-item$="item$" let-index="index">
<input id="item-{{index}}" type="checkbox" [(ngModel)]="" formControlName="userGroupParent"/> {{item.gender | uppercase}}
</ng-template>
<ng-template ng-option-tmp let-item="item" let-item$="item$" let-index="index">
<input id="item-{{index}}" type="checkbox" [(ngModel)]="" formControlName="userGroupChild"/> {{item.name}}
</ng-template>
</ng-select>
I have used the same data of the multiselect-checkbox-- [items]="userGroupsList"
https://github.com/ng-select/ng-select/blob/master/demo/app/shared/data.service.ts -- getMockPeople() has the data
So here can i use the [(ngModel)] as well as formControlName on the input how can i child elements are selected when the parent is select as in the example
Please help....!
To make this work with formGroup : keep the formControlName on the ng-select who will be bind to your formGroup.
The problem is those input in the template. For me the best solution is to keep using ngModel like in the example. But you must make angular understand that is as nothing to do with the fromGroup so you can add the option standalone on it.
<input id="item-{{index}}" type="checkbox" [(ngModel)]="item$.selected" [ngModelOptions]="{ standalone : true }" />
There is an other way to do that without the ngModel :
<input id="item-{{index}}" type="checkbox" [checked]="item$.selected" />
My dropdown item was not getting selected on clicking the item in the dropdown, it was only getting checked on clicking on the checkbox. This worked for me thanks

toggle a checkbox attribute on a array of items in a carousel in Angular 2/Typescript

I have this carousel. Each item in the carousel has a checkbox above it. I want to be able to click on item and the checkbox gets a checked attribute. The code does this. The only problem I'm having is it toggles all check boxes in the carousel. I just want it to toggle the one clicked.
<tshq-carousel [dataSource]="brands" [selections]="selectedBrands" (select)="onItemsSelected($event)" [changeKey]="changeKey" [pageSize]="5" [circular]="false"
[enableSelection]="true" mode="single">
<ng-template let-brand>
<ng-container [ngSwitch]="brand.icon&&brand.icon.length>0">
<ng-container *ngSwitchCase="true" >
<label class="apply carousel-checkbox">
<input type="checkbox" id="brandCheck" [checked]="isChecked" value="no" name = "brand">
</label>
<img [src]="formatLogo(brand.icon)" style="max-width:150px" (click)="isChecked = !isChecked" />
</ng-container>
</ng-container>
</ng-template>
</tshq-carousel>
You use isChecked variable to binding to all input checkbox of carousel, so when you change value (check or uncheck) 1 input checkbox, it also set to all remain ones.
I suggest you add 1 property to model brand and use it to binding to input checkbox or image.
Ex:
<tshq-carousel [dataSource]="brands" [selections]="selectedBrands" (select)="onItemsSelected($event)" [changeKey]="changeKey" [pageSize]="5" [circular]="false"
[enableSelection]="true" mode="single">
<ng-template let-brand>
<ng-container [ngSwitch]="brand.icon && brand.icon.length>0">
<ng-container *ngSwitchCase="true" >
<label class="apply carousel-checkbox">
<input type="checkbox" id="brandCheck" [checked]="brand.isChecked" value="no" name="brand">
</label>
<img [src]="formatLogo(brand.icon)" style="max-width:150px" (click)="brand.isChecked = !brand.isChecked" />
</ng-container>
</ng-container>
</ng-template>
</tshq-carousel>