We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Grid date format Problem!

When i apply date format from ts file grid data is not shown. Contrary when i removed on html grid works and data is shown. In addition i applied pageSettings and there is no problem with it. What is the problem ?

<kt-portlet [class]="'kt-portlet--height-fluid'">
  <kt-portlet-header [title]="'Order Statistics'">
  </kt-portlet-header>
  <kt-portlet-body>
    <div class="control-section">
      <ejs-grid [dataSource]='gridDataSource' allowPaging='true' height=365  [pageSettings]='initialPage' >
          <e-columns>
              <e-column field='description' headerText='Paket Adı' width='120' textAlign='Right'></e-column>
              <e-column field='price' headerText='Ücret' width='150'></e-column>
              <e-column field='createdAt' headerText='Oluşturulma Tarihi' [format] = 'formatoptions' width='130' textAlign='Right'></e-column>                    
          </e-columns>
      </ejs-grid>  
    </div>
  </kt-portlet-body>
</kt-portlet>






@Component({
  selector: 'kt-packagegroups',
  templateUrl: './packagegroups.list.component.html',
  styleUrls: ['./packagegroups.list.component.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush
})

export class PackageGroupsListComponent implements OnInit {

  packageGroupsIPackageGroup[] = [];
  gridDataSourceObject[] = [];
  public formatoptions = { format: 'dd/MM/yyyy' }  
  public initialPage = { pageSizes: truepageCount: 4 }; 
  
  constructor(private dataServicePackageDataServiceprivate packageGroupServicePackageGroupServiceprivate cdrChangeDetectorRef) {
  }

  ngOnInit() {      
    this.packageGroupService.getPackageGroups().subscribe(response => {
      this.gridDataSource = response;
    }); 
    this.cdr.detectChanges();            
  }
}

3 Replies

DR Dhivya Rajendran Syncfusion Team February 5, 2020 08:46 AM UTC

Hi Tümer, 
 
Greeting from Syncfusion support. 
 
We have validated the provided information and we suspect that the first value of the date column might be null or undefined so that it cause the reported problem. By, default, when you are not specified the type for the column then it considered from the first value of the column so we suggest you to specify the type for column to resolve the problem. 
 
<ejs-grid [dataSource]='data' height='350'> 
  <e-columns> 
      <e-column field='OrderID' headerText='Order ID' width='120' textAlign='Right'></e-column> 
      <e-column field='CustomerName' headerText='Customer Name' width='150'></e-column> 
      <e-column field='OrderDate' headerText='Order Date' type='date' width='130' [format]="format" textAlign='Right'></e-column> 
  </e-columns> 
</ejs-grid> 
 
 
export class AppComponent { 
  public data: Object[] = []; 
  public format = {type:'date', format:'dd/MM/yyyy'} 
} 
 
 
 
 
If you still face the problem then bind actionFailure event for grid and get back to us with the arguments details that will help us to validate further at our end. 
 
 
Regards, 
R.Dhivya 



Tümer February 8, 2020 10:59 AM UTC

Hi Dhivya,

That's working now. Thank you!

Bests,
Tümer



DR Dhivya Rajendran Syncfusion Team February 10, 2020 05:42 AM UTC

Hi Tümer, 
 
Thanks for your update. 
 
We are happy to hear that the provided suggestion was helpful to resolve the problem. Please get back to us if you require further assistance. 
 
Regards, 
R.Dhivya 


Loader.
Up arrow icon