Utilize the expert capabilities within #dateHeaderTemplate in the Angular component schedule by Syncfusion

I am trying to access the template #dateHeaderTemplate in order to retrieve the ID of the professional who is scheduled to attend the appointment. This information is needed to display the start and end times of the day in the header.

By visiting this link, you can see that we have the ability to customize the elements in the #dateHeaderTemplate header.

If there is a method similar to obtaining the percussion value as in the #resourceHeaderTemplate, I should be able to retrieve the professional ID.

component.ts:

  public getStartTimeAndEndTime(data): string {

    // values containing data
    // {date: Mon Oct 21 2019 00:00:00 GMT-0300 (Brazil Standard Time), type: "dateHeader"}

    // Need to identify which professional is being covered here

    return '13:30 - 18:30';
  }

  public getDateHeaderText(value: Date): string {
    return this.instance.formatDate(value, { skeleton: 'Ed' });
  }

component.html:

<ng-template #resourceHeaderTemplate let-data>

   <!-- Professional ID displayed here -->

    <div class='template-wrap'>
        <div class="avatar resource-image {{getDoctorImage(data)}}"></div>
        <div class="resource-details">
            <div class="resource-name">{{getDoctorName(data)}}</div>
            <div class="h6">{{ getEspecialidadeName(data) }}</div>
            <div class="h5 text-bold" [ngClass]="{'green-fg': getDoctorStatus(data).type === 'atendendo',
             'secondary-text': getDoctorStatus(data).type === 'away'  }">{{ getDoctorStatus(data).text }}</div>
        </div>
    </div>
</ng-template>

<ng-template #dateHeaderTemplate let-data>
    <div fxLayout="column" fxLayoutAlign="center center">
        <div class="date-text h3 text-bold">{{getDateHeaderText(data.date)}}</div>
        <div class="h6">{{getStartTimeAndEndTime(data)}}</div>
        <!-- 
            In addition to the date, also need the professional ID from ng-template #resourceHeaderTemplate-->
    </div>
</ng-template>
<e-resources>
    <e-resource field='DoctorId' title='Doctor' name='Doctors' [dataSource]='resourceDataSource'
        textField='text' idField='id' colorField='color' workDaysField='workDays' startHourField='startHour'
        endHourField='endHour'>
    </e-resource>

Answer №1

Welcome to Syncfusion.

Instead of trying to retrieve the resource id within the dateHeaderTemplate, we recommend using the scheduler's renderCell event to show the resource start and end hour on the date header. Check out the sample below for reference.

https://stackblitz.com/edit/angular-mf9hdq-au5ue2?file=app.component.ts

onRenderCell(args: RenderCellEventArgs): void {

  // Grabbing the resource data while rendering date header cells
  if (args.elementType == 'dateHeader') {
    let resData: any = this.scheduleObj.getResourcesByIndex(parseInt(args.element.getAttribute('data-group-index'), 10));
    let ele: HTMLElement = createElement('div', {
      innerHTML: ""+resData.resourceData.startHour +" - "+resData.resourceData.endHour,
      className: 'res-name', styles: 'padding-top: 5px'
    });
    (args.element).appendChild(ele);
  }
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Creating Algorithms for Generic Interfaces in TypeScript to Make them Compatible with Derived Generic Classes

Consider the (simplified) code: interface GenericInterface<T> { value: T } function genericIdentity<T>(instance : GenericInterface<T>) : GenericInterface<T> { return instance; } class GenericImplementingClass<T> implemen ...

Should private members be kept confidential during program execution?

While Typescript's "private" members may not be truly private at runtime, traditional closures maintain the privacy of their members. Is there value in ensuring that private members remain private during runtime? ...

Retrieve the data from multiple forms effortlessly with a single click

I'm currently working on getting the results for multiple forms simultaneously. I have a structure in place to retrieve the result one by one, but now I need to send the results of all of them together. Here is my HTML code snippet: <form (ngSubmi ...

Querying data elements using Graphql mutations: a step-by-step guide

const MUTATION_QUERY = gql` mutation MUTATION_QUERY( $name: bigint! ) { insert_name( objects: { name: $name } ) { returning { id name } } } `; const [onClick, { error, data }] = useMut ...

Guide on retrieving a nested JSON array to extract a comprehensive list of values from every parameter within every object

A JSON file with various data points is available: { "success": true, "dataPoints": [{ "count_id": 4, "avg_temperature": 2817, "startTime": "00:00:00", "endTime": "00:19:59.999" }, ... I am trying to extract all the values of & ...

Exploring Angular: How to Access HTTP Headers and Form Data from POST Request

I am currently working with an authentication system that operates as follows: Users are directed to a third-party login page Users input their credentials The website then redirects the user back to my site, including an auth token in a POST request. Is ...

My reselect function seems to be malfunctioning - I'm not receiving any output. Can anyone help me

I'm looking to implement reselect in my code to retrieve the shopping cart based on product ids. Here's my reselect.ts file: import { createSelector } from "reselect"; import { RootState } from "../store"; export const shopp ...

What is the procedure for renaming an item within a basic array in Angular?

I am working on a project in Angular and have constructed an array. I am now looking to change the name of one of the items in this array. While I have figured out how to rename keys in an array, I'm still unsure about how to do so for its values. ...

Lack of intellisense support for .ts files in Visual Studio Code

Currently, I am using Visual Studio Code 1.17.2 on Arch Linux to kickstart my work with Node.js/Angular4. To avoid confusion caused by loosely typed code, I have decided to switch to TypeScript for my NodeJS server as well. This is why my main file is name ...

Passing a custom data type from a parent component to a child component in React

I'm currently working on developing a unique abstract table component that utilizes the MatTable component. This abstract table will serve as a child element, and my goal is to pass a custom interface (which functions like a type) from the parent to t ...

Why am I encountering a 400 error with my mutation in Apollo Client, when I have no issues running it in Playground?

After successfully testing a mutation in the playground, I attempted to implement it in my Apollo client on React. However, I encountered an error message stating: Unhandled Rejection (Error): Network error: Response not successful: Received status code 40 ...

The CLI variation is exclusively designed to work with Angular versions starting from 14.0.0 up

I encountered the following issue: This CLI version is designed to work with Angular versions ^14.0.0, however, I have Angular version 15.0.0 installed. For instructions on updating Angular, please visit: https://update.angular.io/ Even after updating An ...

The issue of ngModel not binding to the value of ion-select in Angular Ionic

Having an ion select outside of a form with an ngModel attribute bound to "selectedValue", I encounter an issue where my selections are not being properly populated in the selectedValue variable even though they appear in the ionChange method. The main pur ...

Launching npm start does not automatically open a browser tab

I'm currently learning angularjs 2 and I'm eager to create my first application using the framework. Following the guidelines on their official website, I proceeded with all the steps outlined in this link. In step 6, I am required to run the com ...

Validating minimum and maximum values with Angular 2 FormBuilder

I am currently developing a form using Angular 2 Formbuilder and I want to ensure that users can only input positive values into the amount field (with a minValue of 0 and maxValue of 100). How can I go about implementing minimum and maximum value validati ...

What is the most effective method for distributing TypeScript functions that are used by services and span multiple components?

I have a set of TypeScript functions that are currently scattered across components. These functions are being duplicated unnecessarily, and I am looking for a way to centralize them so all components can access them without redundancies. Since these fun ...

Reactive forms with Angular CDK drag and drop

I'm facing an issue in this scenario: https://stackblitz.com/edit/angular-asevei?file=app%2Fcdk-drag-drop-sorting-example.html Everything seems to be functioning properly, except that when I drag the select box, it keeps resetting to the first value ...

What steps do I need to take to successfully integrate Firebase authentication with Angular2 FINAL?

After upgrading to Angular2 Final, I completed the migration project steps to transition everything over. Surprisingly, there were no errors during authentication; however, the issue arises post-authentication. Upon redirection back to the page, the authen ...

Is there a way to integrate the AuthState TypeScript Interface into the react-oidc-context Node package for testing in Next.js?

We are currently working on a Next.js application that utilizes the react-oidc-context Node module for authentication with ADFS. During our testing phase using Vitest, we encountered the following error: TypeError: Cannot read properties of undefined (rea ...

What is the procedure for entering the output generated by genMockFromModule when creating a custom mock in Jest?

Looking at my orders directory structure, I have a function in the orders/helpers file that I want to test using a manual Jest mock. orders __mocks__ helpers.ts __tests__ orders.ts helpers.ts orders.ts The orders/helpers.ts file contains ...