Telerik Forums
Kendo UI for Angular Forum
1 answer
26 views
Hi, there, so atm I'm trying to implement a custom filter menu, with kendo multiselect component, but I'm having some issues. So, what's happening it's that the filtering it's not working properly and I think the issue comes beacuse it's not getting the right currentFilter state. When I open the filter button it seems to do the filtering ok, but when I reopen the button, the filters selected previosly don't appear in the ui, despite the filtering persisting and I'm not able to unselect any filter at all, and if i try to filter again selecting new values it will just add the values to the currentFilter and perfoms the filtering adding the new values, plus the ones before. 


custom-component.ts

export class CustomMultiSelectFilterComponent implements AfterViewInit {

  @Output() public handleFilterChange = new EventEmitter<CompositeFilterDescriptor>()

  @Input() public data: string[] = []
  @Input() public textField: string = ""
  @Input() public valueField: string = ""
  @Input() public filter: CompositeFilterDescriptor = { logic: "or", filters: [] }
  @Input() public preFilterValue: string | null = null
  @Input() public filterService: FilterService
  @Input() public currentFilter: CompositeFilterDescriptor = { logic: "or", filters: [] }

  public constructor(
    filterService: FilterService
  ) {
    this.filterService = filterService
  }

  public filterChange(filter: CompositeFilterDescriptor): void {
    this.filter = filter
    this.data = filterBy(this.data , filter)
    this.handleFilterChange.emit(filter)
  }

  public onChange(values: string[], filterService: FilterService): void {
    filterService.filter({
      filters: values.map((value) => ({
        field: this.valueField,
        operator: "contains",
        value,
      })),
      logic: "or",
    })
  }

  public ngAfterViewInit(): void {
    if (this.filterService) {
      this.filterService.changes.subscribe((filter: CompositeFilterDescriptor) => {
        this.currentFilter = filter
        console.log("Current Filters:", this.currentFilter)
      })
    }
  }

}


custom-filter.html

<kendo-multiselect
  [data]="data"  
  [valuePrimitive]="true"
  [textField]="textField"
  [valueField]="valueField"
  [value]="filter | filterValues"
  (valueChange)="onChange($event, filterService)"
  >
</kendo-multiselect>

table.html


<kendo-grid
  kendoGridSelectBy="id"
  [kendoGridBinding]="users"
  filterable="menu"
  [sortable]="true"
  [resizable]="true"
  (selectionChange)="selectionChange($event)"
  [selectable]="selectableSettings"
  [selectedKeys]="[selectedKeyArray]"
  (filterChange)="handleFilterChange($event)"
  [filter]="filter"
>
  <kendo-grid-column-group title="{{ 'literal:Users | Total:' | translate }} {{ users.length }}" [columnMenu]="true">
    <kendo-grid-column field="roles" title="{{ 'literal:Roles' | translate }}" [width]="220" [headerStyle]="{ 'font-weight': 'bold' }">
      <ng-template kendoGridFilterMenuTemplate let-filter="filter" let-filterService="filterService">
        <app-custom-multiselect-filter
          [data]="rolesToFilter"
          textField="rolesToFilter"
          valueField="filterRoles"
          [preFilterValue]="preFilter"
          [filterService]="filterService"
          [currentFilter]="filter"
          >
        </app-custom


Yanmario
Telerik team
 answered on 02 Jan 2024
0 answers
45 views

Howdy, I am trying to make a right click context menu when you right click on an scheduled event in the scheduler.  I have gotten it mostly working however when I right click on an event the context menu appears about 25 pixels or so below the mouse cursor(see screenshot).  I would prefer it to work like every other context menu which is aligned with the mouse cursor.  The code below seems pretty basic.  In testing I also removed all CSS to ensure there wasn't something causing issues there.  Due to the nature of the context menu I can't inspect the element properly in Chrome's console.  The target element is the scheduled event which I can confirm through console.

 

So how do I make the right click menu actually show up along the mouse when clicking an appt?

 

I have spent the past two days of stripping code and adding it back so in my code below there will be some things that aren't necessary but it shouldn't bog down any troubleshooting.
import { Component, ViewChild, ElementRef, ViewChildren, QueryList } from '@angular/core';
import { ApptDetail } from '../../interfaces/apptdetail.interface';
import { SchedulerEvent, } from '@progress/kendo-angular-scheduler';
import valueHelpers from '../../shared/value-helpers';
import { ApptService } from '../../interfaces/services/appt.service';
import { GenericPagedResponse } from '../../interfaces/pagedresponse.interface';
import { Client } from '../../interfaces/client.interface';
import { ClientService } from '../../interfaces/services/client.service';
import { ContextMenuComponent, ContextMenuSelectEvent, ContextMenuPopupEvent } from '@progress/kendo-angular-menu';

@Component({
  selector: 'app-appointments',
  templateUrl: './appointments.component.html',
  styleUrls: ['./appointments.component.css']
})
export class AppointmentsComponent {
  public appointments: ApptDetail[] = [];
  selectedDate: Date = new Date();
  public contextMenuEvent!: SchedulerEvent;
  @ViewChild(ContextMenuComponent, { static: true }) apptContextMenu!: ContextMenuComponent;
  @ViewChild('apptScheduler', { read: ElementRef }) apptScheduler!: ElementRef;
  @ViewChildren('apptEvent', { read: ElementRef }) apptEventElements!: QueryList<ElementRef>;

  apptContextMenuItems: any[] = [
    {
      text: "Cashout Appointment",
      value: "cashout"
    },
    {
      text: "Edit",
      value: "edit",
    },
    {
      text: "Delete",
      value: "delete"
    },
    {
      text: "Send SMS Reminder",
      value: "sendSMS"
    },
    {
      text: "Send Email Reminder",
      value: "sendEmailReminder"
    },
  ];


  ngOnInit() {
    this.loadApptData();
  }

  constructor(private apptService: ApptService) { }

  loadApptData() {
    console.log("Load appt data");

    const fromDate = valueHelpers.getStartOfWeek(this.selectedDate);
    const toDate = valueHelpers.getEndOfWeek(this.selectedDate);


    this.apptService.getApptsForCalendar(fromDate, toDate).subscribe((data: GenericPagedResponse<ApptDetail>) => {
      this.appointments = data.data;


      // Update the schedulerEvents array with the new data
      this.updateSchedulerEvents();
    });
  }

  private updateSchedulerEvents() {
    this.schedulerEvents = this.appointments.map(appointment => {

      const startDateTime = new Date(appointment.startDateTime); // Convert to Date object
      const endDateTime = new Date(appointment.endDateTime); // Convert to Date object


      return {
        id: appointment.apptDetailId.toString(),
        start: startDateTime,
        end: endDateTime,
        title: appointment.clientName + ' <br> ' + appointment.itemName,
        description: appointment.apptNote,       
        resourceId: appointment.employeeId
      };
    });
  }

  public schedulerEvents: SchedulerEvent[] = [];

  onDateChange(event: any) {
    console.log(event);
    if (this.selectedDate != event.selectedDate)
      this.selectedDate = event.selectedDate;
    console.log('Selected Date:', this.selectedDate);
    this.loadApptData();
  }


  public onApptContextMenuSelect(e: ContextMenuSelectEvent): void {
    if (e.item.value == "edit") {

    }
    else if (e.item.value == "delete") {

    }
    else if (e.item.value == "cashout") {

    }
    else if (e.item.value == "sendSMS") {

    }
    else if (e.item.value == "sendEmailReminder") {

    }

  }
  public onEventContextMenu(event: any): void {
    this.contextMenuEvent = event; // Save the event for later use

    const targetElement = event.target;

    // Get the unique identifier from the custom attribute
   // const apptId = targetElement.getAttribute('data-appt-id');

    // Find the corresponding 'apptEvent' element based on the 'data-appt-id' attribute

   // console.log(apptId)
    
    if (targetElement) {

      
      this.apptContextMenu.show(targetElement);
    }

    event.preventDefault();
  }

}

<kendo-scheduler [events]="schedulerEvents" (dateChange)="onDateChange($event)" [selectedDate]="selectedDate"
                 (contextmenu)="onEventContextMenu($event)" #apptScheduler>

  <kendo-scheduler-week-view> </kendo-scheduler-week-view>

</kendo-scheduler>


<kendo-contextmenu #apptContextMenu [items]="apptContextMenuItems"  (select)="onApptContextMenuSelect($event)">

</kendo-contextmenu>


Sean
Top achievements
Rank 1
 asked on 06 Aug 2023
1 answer
47 views

Hi,

i'm trying to order the items of the "columns" option of angular kendo grid columnMenu , like the jQuery version.

There is a way to do that?

Thanks.

Hetali
Telerik team
 answered on 28 Jun 2023
0 answers
105 views

cssClass not working in kendo-menu-item (cssStyle works)

HTML:

<kendo-menu>
<kendo-menu-item text="1" cssClass="x">
<kendo-menu-item text="1.1"></kendo-menu-item>
<kendo-menu-item text="1.2"></kendo-menu-item>
</kendo-menu-item>
</kendo-menu>

LESS:

.x {
background-color: red;
}

Module:

import { MenusModule } from '@progress/kendo-angular-menu';

const telerikModules = [
...
MenusModule,
...
];

@NgModule({
imports: telerikModules,
exports: telerikModules,
})
export class TelerikModule {
}

 

Dmitry
Top achievements
Rank 1
 updated question on 12 Mar 2023
1 answer
51 views

Hi,

I have a kendo-dropdownlist and I want to override the style of the kendo-popup. I want to change the font as well as change the style for the selected item (see attached file) like the background color, etc...

How do I go about doing this? I've tried styling using pseudo ::ng-deep, :host ::ng-deep to using the classes .k-popup, the li's .k-list-item, etc..

Thanks!

 

Jaime

Hetali
Telerik team
 answered on 15 Feb 2023
1 answer
96 views

Hi All,

I have a drawer component set up as my application's side bar navigation.  I am using a kendoDrawerItemTemplate to allow some customisation of the menu items' appearances.

If I don't use kendoDrawerItemTemplate and just leave the default styling, when an item has children I get the collapse arrow to expand and contract the level.  When using the kendoDrawerItemTemplate I would obviously need to include this, I can't find anything in the docs about how to pull this bit in.

I have something like this:

<ng-template kendoDrawerItemTemplate let-item let-level="level">
        <div
          style="
            display: flex;
            align-items: center;
            padding-bottom: 3px;
            padding-top: 3px;
          "
        >
          <span
            [ngClass]="'k-icon ' + item.icon"
            [themeColor]="primary"
            size="medium"
          ></span>
          <span class="k-item-text">{{ item.text }}</span>
          <span
            *ngIf="item.children"
            class="k-icon k-panelbar-expand k-i-arrow-60-down"
          ></span>
        </div>
      </ng-template>

The span with the *ngIf children I know is wrong but it is there that I want to pull in the component / code for the arrow if possible.

 

Does anyone know the answer as to how I achieve this?

 

Many Thanks,

Richard
Top achievements
Rank 1
Iron
 answered on 06 Feb 2023
0 answers
39 views

I have a kendo-menu in the upper right corner of the window. When the menu items are pulled down, there is an ugly moment where the menu seems to be partially offscreen, the scrollbar appears and then the menu shifts back on screen and the scrollbar disappears. I was wondering if I could fix this by forcing the menu to appear onscreen. I don't see anything in the api to set the initial position.

Philip
Top achievements
Rank 1
Iron
 asked on 23 Jan 2023
1 answer
113 views

Trying out the new fluent theme, most components are looking good but the menu looks very condensed, even in the examples.


https://www.telerik.com/kendo-angular-ui/components/menus/menu/

 

 

Can this be fixed?

 

 

Martin
Telerik team
 answered on 16 Sep 2022
0 answers
61 views

Hi,

Any one help me to bind  kendo-menu items with enabled / disabled

My code:

 <kendo-menu [items]="toolbarItems" (select)="toolbarItemClick($event)">
            <ng-template kendoMenuItemTemplate let-item="item">
                <i [ngClass]="item.icon"></i>
                {{ item.text }}
            </ng-template>       

</kendo-menu>

 

this.toolbarItems=[
      {
        id:1,
        text:"New User",
        icon:"fa-regular fa-user-plus",
        isVisible:this.IsVisibleCreateUser,
        isEnable:this.IsEnabledCreateUser        
      },
      {
        id:2,
        text:"Update",
        icon:"fa-regular fa-pen-to-square",
        isVisible:this.IsVisibleUpdate,
        isEnable:this.IsEnabledUpdate        
      },
     
    ]

 

Developer
Top achievements
Rank 1
 asked on 17 Aug 2022
0 answers
146 views

 

I have attached screenshot of report and index.html file. report rendering in my tr-viewer but icons only came as box. could you please help me to clear this issue in angular. Angular 10version i am using
Mohan
Top achievements
Rank 1
 updated question on 01 Mar 2022
Top users last month
Dominik
Top achievements
Rank 1
Giuliano
Top achievements
Rank 1
Dominic
Top achievements
Rank 1
Glendys
Top achievements
Rank 1
NoobMaster
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?