Search results

Display null date values at the bottom of the grid in Vue Grid component

By default the null values are displayed at bottom of the Grid row while perform sorting in ascending order. As well as this values are displayed at top of the Grid row while perform sorting with descending order. But you can customize this default order to display the null values at always bottom row of the Grid by using column.sortComparer method.

In the below demo we have displayed the null date values at bottom of the Grid row while sorting the OrderDate column in both ways.

    <div id="app">
        <ejs-grid :dataSource='data' :allowSorting='true' :actionBegin='actionBegin'>
                <e-column field='OrderID' headerText='Order ID' width=100></e-column>
                <e-column field='CustomerID' headerText='Customer ID' width=120></e-column>
                <e-column field='OrderDate' headerText='Order Date' format='yMd'  :sortComparer='sortComparer' width=120></e-column>
                <e-column field='ShipCountry' headerText='Ship Country' width=150></e-column>
import Vue from "vue";
import { GridPlugin, Sort } from "@syncfusion/ej2-vue-grids";
import { data } from './datasource.js';

let action;

export default {
  data: () => {
    return {
      data: data
  methods: {
    sortComparer: function(reference, comparer) {
        let sortAsc = action === "Ascending" ? true : false;
        if (sortAsc && reference === null) {
            return 1;
        else if (sortAsc && comparer === null) {
            return -1;
        else if (!sortAsc && reference === null) {
            return -1;
        else if (!sortAsc && comparer === null) {
            return 1;
        } else {
            return reference - comparer;
    actionBegin: function(args) {
        if (args.requestType == "sorting") {
            action = args.direction;
  provide: {
    grid: [Sort]
  @import "../node_modules/@syncfusion/ej2-vue-grids/styles/material.css";