Not null, Null, Empty, Not empty are not working with - Filter template


import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { GridModuleFilterServicePageServicefrom '@syncfusion/ej2-angular-grids'
import { MultiSelectModuleCheckBoxSelectionService,DropDownListAllModule } from '@syncfusion/ej2-angular-dropdowns'
import { CheckBoxModule } from '@syncfusion/ej2-angular-buttons'



import { ComponentOnInit } from '@angular/core';
import { data } from './datasource';
import { FilterSettingsModel } from '@syncfusion/ej2-angular-grids';

@Component({
imports: [
        
        GridModule,
        MultiSelectModule,
        DropDownListAllModule,
        CheckBoxModule
    ],

providers: [FilterServicePageService,CheckBoxSelectionService],
standalone: true,
    selector: 'app-root',
    template: `<ejs-grid [dataSource]='data' [allowFiltering]='true' [filterSettings]='filterOptions' height='273px'>
                <e-columns>
                    <e-column field='OrderID' headerText='Order ID' textAlign='Right' width=100>
                    <ng-template #filterTemplate let-data>
                        <input
                          autocomplete="off"
                          class="e-input e-control" 
                          type="text"
                          placeholder="Enter Order id"
                          value="{{ data?.value }}"
                        />
                      </ng-template>
                    </e-column>
                    <e-column field='CustomerID' headerText='Customer ID' width=120></e-column>
                    <e-column field='OrderDate' headerText='Order Date' format='yMd' width=100></e-column>
                    <e-column field='Verified' headerText='Verified' [displayAsCheckBox]'true' width=100></e-column>
                    <e-column field='ShipName' headerText='Ship Name' width=100></e-column>
                </e-columns>
                </ejs-grid>`
})
export class AppComponent implements OnInit {

    public data?: object[];
    public filterOptions?: FilterSettingsModel;

    ngOnInit(): void {
        this.data = data;
        this.filterOptions = {
           type: 'Menu',
        };
    }
}


I am using latest version ejs grid. when I try to use filter template and filter with null, not null, empty and not empty
It throws an error and could not continue further


Image_5882_1720801010483




15 Replies

VS Vikram Sundararajan Syncfusion Team July 18, 2024 12:42 PM UTC

Hi Sivasakthi Nithyanantham,


Thanks for your patience and understanding.


We have confirmed that the reported behavior is an issue from our side and have logged it as "Not null, Null, Empty, Not empty are not working with - Filter template ". Thank you for taking the time to report this issue and helping us improve our product. At Syncfusion, we are committed to fixing all validated defects(subject to technical feasibility and Product Development Life Cycle ) and will include the defect fix in our upcoming patch release which will be rolled out on "August 07 , 2024".


You can now track the current status of your request, review the proposed resolution timeline, and contact us for any further inquiries through the below link,


Feedback: https://www.syncfusion.com/feedback/59602/not-null-null-empty-not-empty-are-not-working-with-filter-template


Disclaimer: "Inclusion of this solution in the weekly release may change due to other factors including but not limited to QA checks and works reprioritization".


Regards,

Vikram S



AR Aishwarya Rameshbabu Syncfusion Team August 6, 2024 03:50 PM UTC

Hi Sivasakthi Nithyanantham,

 

We are glad to announce that, we have included the fix for the issue “Not null, Null, Empty, Not empty are not working with - Filter template” in our 26.2.8 release. So please upgrade to our latest version of the Syncfusion package to resolve the reported issue.

 

Root Cause: The root cause of the issue occurs when we provide the filter template; at that time, ej2_instances are not present, causing the issue.

 

Solution: Fixed the issue by adding a condition to check whether ej2_instances is present or not, including checks for null, not null, empty, and non-empty values.

 

Sample: Wz88kh (forked) - StackBlitz

   

Feedback: https://www.syncfusion.com/feedback/59602/not-null-null-empty-not-empty-are-not-working-with-filter-template

 

We thank you for your support and appreciate your patience in waiting for this release. Please get back to us if you need any further assistance.


Regards,

Aishwarya R



SN Sivasakthi Nithyanantham August 12, 2024 01:13 PM UTC

It throws run time error when click on filter icon here is the error

Image_9605_1723468392927



AR Aishwarya Rameshbabu Syncfusion Team August 13, 2024 02:02 PM UTC

Hi Sivasakthi Nithyanantham,


We apologize for the inconvenience caused. You are still encountering a script error after filtering a record and reopening the filter dialog. We have confirmed that the reported case is an issue from our side and logged it as “A script error occurs when using the filter template, after applying the filter and reopening the filter dialog”. Thank you for taking the time to report this issue and helping us improve our product. At Syncfusion, we are committed to fixing all validated defects (subject to technical feasibility and Product Development Life Cycle ) and will include the defect fix in our upcoming patch release which will be rolled out on “August 20th, 2024”.


You can now track the current status of your request, review the proposed resolution timeline, and contact us for any further inquiries through the below link,


Feedback: https://www.syncfusion.com/feedback/60383/script-error-occurs-when-using-the-filter-template-after-applying-the-filter-and


Disclaimer: "Inclusion of this solution in the weekly release may change due to other factors including but not limited to QA checks and works reprioritization".


Regards

Aishwarya R



AR Aishwarya Rameshbabu Syncfusion Team August 20, 2024 03:21 PM UTC

Hi Sivasakthi Nithyanantham,

 

We are glad to announce that, we have included the fix for the issue “A script error occurs when using the filter template, after applying the filter and reopening the filter dialog” in our 26.2.10 release. So please upgrade to our latest version of the Syncfusion package to resolve the reported issue.

 

Root Cause: The issue arises because the ‘ej2_instances’ is missing when the filter template is provided.

 

Solution: The issue was resolved by incorporating a condition to verify the presence of 'ej2_instances'. This condition includes checks for null, not null, empty, and non-empty values.

 

Sample: https://stackblitz.com/edit/angular-mpby9p-zmkzqs?file=src%2Fapp.component.ts,package.json,src%2Fdata.ts

   

Feedback: https://www.syncfusion.com/feedback/60383/script-error-occurs-when-using-the-filter-template-after-applying-the-filter-and

 

We thank you for your support and appreciate your patience in waiting for this release. Please get back to us if you need any further assistance.

 

 

Regards,

Aishwarya R



SN Sivasakthi Nithyanantham August 26, 2024 06:18 AM UTC

It works. Thanks for your update



JS Johnson Soundararajan S Syncfusion Team August 27, 2024 07:39 AM UTC

Hi Sivasakthi Nithyanantham,


You're welcome! Please feel free to contact us if you need any other assistance.


Regards,

Johnson Soundararajan S




SN Sivasakthi Nithyanantham August 29, 2024 11:26 AM UTC

Noticed below issues

  1. When I select empty/not empty from its not clear already given input in text/field used for fitler
  2. When i use as   <ejs-datepicker filter template , its not disabling field when select empty/non empty from filter dropdown list Image_1278_1724925446966Image_6767_1724930752752
  3. Is there any event to listen filter option change event.   I mean is it possible to listen the change of highlighted dropdown below                                                                                                      Image_7295_1724925446966
Please help me to fix these issues 


VK Vasanthakumar K Syncfusion Team September 2, 2024 08:02 AM UTC

Hi Sivasakthi Nithyanantham,


#Q1. When I select empty/not empty from its not clear already given input in text/field used for filter.

#Q2. When i use as   <ejs-datepicker> filter template, it’s not disabling field when select empty/nonempty from filter dropdown list.

#Q3. Is there any event to listen filter option change event. I mean is it possible to listen the change of menu type filter operator dropdownlist.


We have validated your query and understand that you need assistance with menu-type filter template customization when switching the menu-type filter operator of the grid to empty/non-empty. By default, the grid’s menu-type filter value input maintains the grid’s filter or user-changed value. The grid will not change the user input unless specifically instructed. Therefore, only when selecting 'empty', 'not empty', 'null', and 'not null', the grid will disable the value component with the filtered or user-selected value.


However, if you want to customize this behavior to clear the value programmatically, you can override the operator dropdown list change event to listen and handle your filter template customization (such as disabling and clearing the value from the filter template component) to achieve your requirement.


We have prepared a customization sample for your reference. In that sample, we override the menu-type filter operator dropdown list change event to handle customization according to your filter template customization requirement. Please refer to the code example and working sample below for more details.


[code example]

<ejs-grid

      . . . . . .

      #grid

      [allowFiltering]="true"

      [filterSettings]="filterOptions"

      (actionComplete)="actionComplete($event)"

    >

    <e-columns>

             . . . . . . .

             <e-column field='OrderDate' headerText='Order Date' format='yMd' width=100>

                  <ng-template #filterTemplate let-data>

                      <ejs-datepicker

                          value="{{ data?.value }}"

                          format="MM/dd/yyyy"

                          placeholder="MM/DD/YYYY">

                      </ejs-datepicker>

                  </ng-template>

             </e-column>

             . . . . . . .

     </e-columns>

</ejs-grid>

actionComplete(args: FilterMenuRendererArgs) {

    if (args.requestType === 'filterAfterOpen' && args.filterModel['flMuiObj']) {

      args.filterModel['flMuiObj'].dropOptr.change = function(

        args: ChangeEventArgs

      ) { // here you can listen menu type filter operator dropdownlist value change.

        const valInput: HTMLInputElement = args.element.closest('.e-flmenu-maindiv').querySelector('.e-flmenu-valuediv .e-control');

        if (

          args.value === 'isempty' ||

          args.value === 'isnotempty' ||

          args.value === 'isnotnull' ||

          args.value === 'isnull'

        ) {

          if (!isNullOrUndefined(valInput['ej2_instances'])) {

            valInput['ej2_instances'][0]['enabled'] = false; // disable filter menu template datepicker input here.

            valInput['ej2_instances'][0].value = null; // reset template datepicker value here at the time of select empty/not empty.

          } else {

            valInput.setAttribute('disabled', 'true');

          }

        } else if (!isNullOrUndefined(valInput.getAttribute('disabled')) || (valInput.querySelector('input') && !isNullOrUndefined(valInput.querySelector('input').getAttribute('disabled')))) {

          if (!isNullOrUndefined(valInput['ej2_instances'])) {

            valInput['ej2_instances'][0]['enabled'] = true; // enable filter menu template datepicker input here

          } else {

            valInput.removeAttribute('disabled');

          }

        }

      };

}


Sample: 189325-filter-menu-template-empty - StackBlitz


Regards,

Vasanthakumar K



SN Sivasakthi Nithyanantham September 10, 2024 04:04 AM UTC

Hi Syncfusion ,


Thanks for the support.


Facing one more issue in updated version I have tried in versions 26.2.10 to 26.2.12


I have added below properties to grid 

Image_3173_1725940964258


Frozen column works but when try to scroll horizontally, header is not scrolling correctly. It fixed and not scrolling along with values


Please help me to fix this


Note: I have tried isFrozen="true" and freeze="Left" too. 



AR Aishwarya Rameshbabu Syncfusion Team September 11, 2024 05:09 AM UTC

Hi Sivasakthi Nithyanantham,


Based on the provided information, we have observed that you are experiencing difficulties with enabling frozen columns in the Syncfusion Grid where the header does not scroll properly with the content while scrolling horizontally. We have developed a sample using the provided details, but we were unable to reproduce the reported issue. Please refer to the sample and video demonstration below, which illustrate proper synchronization between the header and content during horizontal scrolling.


Sample: 43kzte (forked) - StackBlitz


If the issue persists, kindly provide the following details to facilitate further validation:

1. The complete Grid rendering code, including the event handler functions associated with the events used in your Grid.

2. The type of data binding utilized in the Grid (Remote or Local). If remote data binding is used, please share the adaptor details.

3. A simple sample that replicates the issue or an attempt to replicate the issue using the provided sample.

4. A video demonstration showing the issue replication.


Regards

Aishwarya R



SN Sivasakthi Nithyanantham September 13, 2024 04:48 AM UTC

HI Syncfusion team,


In you above sample code, I have just added hide columns in databound as below 

import { ComponentOnInitViewChild } from '@angular/core';
import { data } from './data';
import {
  PageService,
  SortService,
  FilterService,
  ToolbarService,
  EditService,
  GridModule,
  ResizeService,
  GridComponent,
from '@syncfusion/ej2-angular-grids';

@Component({
  selector: 'app-root',
  templateUrl: 'app.component.html',
  providers: [
    PageService,
    SortService,
    FilterService,
    ToolbarService,
    EditService,
    ResizeService,
  ],
  standalone: true,
  imports: [GridModule],
})
export class AppComponent {
  @ViewChild('grid'gridGridComponent;
  public dataObject[];
  public pageSettingsObject;
  public filterSettingsObject;
  public toolbarstring[];
  public editSettingsObject;
  public orderidrulesObject;
  public customeridrulesObject;
  public freightrulesObject;
  public sortSettingsObject;

  ngOnInit(): void {
    this.data = data.slice(010);
    this.pageSettings = { pageCount: 5 };
    this.filterSettings = { type: 'Excel' };
    this.toolbar = ['Add''Edit''Delete''Update''Cancel'];
    this.editSettings = {
      allowEditing: true,
      allowAdding: true,
      allowDeleting: true,
    };
    this.orderidrules = { required: truenumber: true };
    this.customeridrules = { required: trueminLength: 5 };
    this.freightrules = { required: truemin: 0 };
    this.sortSettings = {
      columns: [{ field: 'CustomerName'direction: 'Descending' }],
    };
  }

  databound(): void {
    this.grid.hideColumns('Order Date');
  }
}

and in html just added below change

Image_2135_1726202894322

Now the scroll is not working as expected


Thanks

Sivasakthi N



DM Dineshnarasimman Muthu Syncfusion Team September 16, 2024 02:18 PM UTC

Hi Sivasakthi,


We have reviewed your query about grid not properly scrolling horizontally when hideColumns method is used along with frozenColumns. We have validated this from our end, we suggest you to use the hideColumns method in the created event of the grid, or use the hideColumn in the dataBound event of the grid with a flag variable.


The code snippet has been attached for your reference. Please implement any one of the following.


1. using databound with flag variable:


  dataBound() {

    if (this.isInitial) {

      this.grid.hideColumns('Order Date');

      this.isInitial = false;

    }

  }

 


2. using created event:


 created() {

    this.grid.hideColumns('Order Date');

  }

 


Sample: https://stackblitz.com/edit/angular-pddfns-nsgen7?file=src%2Fapp.component.html


Please get back to us if you need any further assistance.


Regards,

Dineshnarasimman M



SN Sivasakthi Nithyanantham September 18, 2024 06:48 AM UTC

Hi 

Above fix not works for me.

  1. Loading data from server
  2. wants to hide column based on response from other server request
  3. If i use grid created to hide column or after getting response from #2 call from above. Column header get hided but content not
  4. It works fine when i use in databound where there is no frozen column but with frozen and databound with above flag check option, it hides column header but not content
Note: I could not able to recreate in sample 



Thanks

Sivasakthi



SI Santhosh Iruthayaraj Syncfusion Team September 18, 2024 02:08 PM UTC

Hi Sivasakthi Nithyanantham,


Based on the details provided, we have created a sample where the data is fetched through an API call, and the columns to be hidden are also retrieved from the API. However, we were unable to replicate the reported issue on our side. Please review the sample provided below for your reference:


Sample: https://stackblitz.com/edit/angular-grid-u7mdtf-stzcc6


We suspect the issue you're encountering might be due to a customization problem when invoking the hideColumns method. To investigate further and provide a more accurate solution, kindly share the following details:


  1. The complete Grid rendering code, including all properties and event bindings (ensure to include any customizations done within the events and all columns used in the Grid).
  2. The code responsible for retrieving data from the server and binding it to the Grid, as well as the code fetching the columns to be hidden and calling the hideColumns method accordingly.
  3. Any console errors observed during the issue replication, along with a video demonstration replicating the problem and showing the console errors.
  4. The version of the Syncfusion packages you're using (including the Grid and other Syncfusion packages).
  5. You can also attempt to replicate the issue using the currently provided sample, as it has been prepared based on the details you shared.


Once we receive these details, we will be able to assist you more effectively in resolving the issue.


Regards,

Santhosh I


Loader.
Up arrow icon