Syncfusion grid issue with Date filter

Hi,

In the filtering option of ejs grid contain a column having dates and as well as blanks . I need to ensure that the blanks are passed as a string ("blanks"), consistent with how it is handled on the backend. However, when using the filter option in Syncfusion's EJ2 Grid, the filter payload isn't handling this as expected.


 how to adjust the filter event to correctly pass blanks as a string and modify the condition check for the filter properties in Syncfusion?


3 Replies

VS Vikram Sundararajan Syncfusion Team October 15, 2024 12:58 PM UTC

Hi Adarsh N P,


Greetings from Syncfusion support,


We understand your query regarding the filtering option in the Syncfusion EJ2 Grid, specifically the need to send blanks in the date column as a string ("blanks"). To accomplish this, you can modify the actionBegin event of the grid. By checking if the filter value is empty for the date column and replacing it with a string (like " "), you can ensure it is handled correctly on the backend. Here’s a simple code snippet:


methods: {

  onActionBegin(args) {

    if (args.requestType === "filtering" && args.columns) {

      args.columns.forEach((filter) => {

        if (filter.field === "OrderDate") {

          if (!filter.value) {

            filter.value = " "; // Replace empty value with a string

          }

        }

      });

    }

  },

}


Sample: https://stackblitz.com/edit/qctekr-ez3dqz?file=src%2FApp.vue


Please get back us if you need further assistance.


Regards,

Vikram S



AN Adarsh N P October 16, 2024 02:20 PM UTC

Hi Vikram,

I implemented the solution you provided, but it's not working as expected. I'm still facing an issue with the date column filter. I need to send "blanks " in the date column as the string “blanks” .When the frontend passes these blanks to the backend, I want them to be recognized and processed as expected

when i pass above solution 

 if (!filter.value) {

            filter.value = "blanks "; 

          }
it shows invalid dateIMG-20241016-WA0028.jpg


When we provide a "blanks" as value, the value argument is considered an invalid date.



VS Vikram Sundararajan Syncfusion Team October 21, 2024 11:12 AM UTC

Hi Adarsh N P,


We understand that you're experiencing an issue with filtering the date column where blanks need to be passed as a string ("blanks"). Before we proceed with providing a solution for this requirement, we need some additional information to offer the most appropriate resolution. Kindly share the following details:


  1. Full Grid Configuration: Please share the complete grid configuration, including the column definitions and any events (like actionBegin or actionComplete) that you are using for filtering.
  2. Data Adapter in use: Let us know which data adaptor you are using for the Grid (e.g., URL adaptor, OData, Web API, or any other).
  3. Date Column Data Structure: How is the date data structured in your data source for the OrderDate column? Are blanks represented as null, empty strings, or in some other format?
  4. Backend Processing: How does your backend handle the date column when receiving a blank value or a placeholder like "blanks"? Is there specific logic for processing these blanks?
  5. Error Messages: Are there any error messages in the browser console or from the backend when passing "blanks" or blank values to the date filter? If so, could you please share those?


We appreciate your cooperation in providing us with the requested information, as it will help us provide a more effective solution to your query.


Regards,

Vikram S


Loader.
Up arrow icon