Presets problem

Hi,

I'm testing angular js2 controls. But in daterange picker, I can't define presets dates. I get this error


If I remove presets, it works fine, and I set this config (your example)

public today: Date = new Date(new Date().toDateString()); public weekStart: Date = new Date(new Date(new Date().setDate(new Date().getDate() - (new Date().getDay() + 7) % 7)).toDateString()); public weekEnd: Date = new Date(new Date(new Date().setDate(new Date(new Date().setDate((new Date().getDate() - (new Date().getDay() + 7) % 7))).getDate() + 6)).toDateString()) ; public monthStart: Date = new Date(new Date(new Date().setDate(1)).toDateString()); public monthEnd: Date = this.today; public lastStart: Date = new Date(new Date(new Date(new Date().setMonth(new Date().getMonth() - 1)).setDate(1)).toDateString()); public lastEnd: Date = this.today; public yearStart: Date = new Date(new Date(new Date().setDate(new Date().getDate() - 365)).toDateString()); public yearEnd: Date = this.today;


<div class="col-md-2">
<ejs-daterangepicker>
<e-presets> <e-preset label="This Week" [start]='weekStart' [end]='weekEnd'></e-preset>
<e-preset label="This Month" [start]='monthStart' [end]='monthEnd'>
</e-preset> <e-preset label="Last Month" [start]='lastStart' [end]='lastEnd'>
</e-preset> <e-preset label="Last Year" [start]='yearStart' [end]='yearEnd'></e-preset>
</e-presets>
</ejs-daterangepicker>
</div>



11 Replies

MC Manolo Capdevila August 3, 2018 09:38 AM UTC

Ups!

I solve this problem. I have a wrong reference


BM Balaji M Syncfusion Team August 6, 2018 07:24 AM UTC

Hi Manolo, 
 
We are glad to hear that you have resolved the issue in your end. Please get back to us if you need any further assistance.  
 
Regards, 
M. Balaji 



SA satyaprasad replied to Manolo Capdevila August 31, 2021 06:33 PM UTC

can u plz help i am also facing same issue



SA satyaprasad replied to Balaji M September 1, 2021 08:32 AM UTC

can u plz help i am also facing same issue



SN Sevvandhi Nagulan Syncfusion Team September 1, 2021 03:33 PM UTC

Hi Satyaprasad, 


Greetings from Syncfusion support. 


We checked your query. The reported issue occurred if you used the presets tag incorrectly. Please refer the below presets sample to resolve the reported issue. 




Regards, 
Sevvandhi N 



SA satyaprasad replied to Sevvandhi Nagulan September 2, 2021 05:15 PM UTC

i copied same what u mentioned in the above link eventhough i am getting error.


i am unable to find the solution



BC Berly Christopher Syncfusion Team September 3, 2021 11:54 AM UTC

Hi Satyaprasad, 
  
We have checked the DateRangePicker component with shared demo code. Unfortunately, the reported issue is not occurred at our end. So, please share any issue reproducing sample that will help us to check and proceed further from our end. 
  
Please find the sample from the below link. 
  
Regards, 
Berly B.C 



SA satyaprasad September 3, 2021 05:48 PM UTC

i shared the component file check once and i installed the dependencies also



can u suggest what exactly required dependencies in nodemodules for daterangepickers

thnx for advance help me 


Attachment: highlitecontentcreate_df8b23d9.zip


BC Berly Christopher Syncfusion Team September 6, 2021 10:53 AM UTC

Hi Satyaprasad, 
  
Thanks for sharing enough information to us.  
  
While checking the shared file, e-presets tag has been missed in the DateRangePicker component tag. So, we suggest you to add the below tag in the application itself. 
  
        <ejs-daterangepicker placeholder='Select a range'> 
            <e-presets> 
                <e-preset  label="This Week" [start]='weekStart' [end]='weekEnd'></e-preset> 
                <e-preset  label="This Month" [start]='monthStart' [end]='monthEnd'></e-preset> 
                <e-preset  label="Last Month" [start]='lastStart' [end]='lastEnd'></e-preset> 
                <e-preset  label="Last Year" [start]='yearStart' [end]='yearEnd'></e-preset> 
            </e-presets> 
        </ejs-daterangepicker> 
 
1.        Also, we need to install the calendars package separately to render the DateRangePicker component without any compilation error with help of “npm install @syncfusion/ej2-angular-calendars --save”.  
2.        After installing the packages, we need to import the DateRangePickerModule in the app.module.ts file to integrate all functionalities in the DateRangePicker component.  
import { BrowserModule } from '@angular/platform-browser'; 
import { NgModule } from '@angular/core'; 
import { FormsModule } from '@angular/forms'; 
import { AppComponent } from './app.component'; 
import { HighliteContentCreateComponent } from './highlite-content-create.component'; 
import {DateRangePickerModulefrom "@syncfusion/ej2-angular-calendars"; 
 
@NgModule({ 
  declarations: [ 
    AppComponent,HighliteContentCreateComponent 
  ], 
  imports: [ 
    BrowserModule, 
    FormsModule,DateRangePickerModule 
  ], 
  providers: [], 
  bootstrap: [AppComponentHighliteContentCreateComponent] 
}) 
export class AppModule { } 
 
3.        After that, we need to import the style for the DateRangePicker component in the “styles.css” file as mentioned below. 
@import '../node_modules/@syncfusion/ej2-base/styles/material.css'; 
@import '../node_modules/@syncfusion/ej2-buttons/styles/material.css'; 
@import '../node_modules/@syncfusion/ej2-inputs/styles/material.css'; 
@import '../node_modules/@syncfusion/ej2-popups/styles/material.css'; 
@import '../node_modules/@syncfusion/ej2-lists/styles/material.css'; 
@import '../node_modules/@syncfusion/ej2-splitbuttons/styles/material.css'; 
@import '../node_modules/@syncfusion/ej2-calendars/styles/material.css'; 
 
  
For your reference, we have prepared the sample and attached it below. 
  
Screenshot: 
 
  
Regards, 
Berly B.C 



JB Jonathan Burn October 28, 2022 03:24 PM UTC

I had the same issue.

The stackblitz example is helpful, and I compared my code with that.

The missing dependency is you need to import the DropDownListModule  as well as the DateRangePickerModule to avoid this "preset" error



UD UdhayaKumar Duraisamy Syncfusion Team October 31, 2022 05:19 AM UTC

Hi Jonathan,


Thanks for the update. Please get back to us if you need any further assistance on this.


Regards,

Udhaya Kumar D


Loader.
Up arrow icon