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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Filter for NULL and empty values

Thread ID:

Created:

Updated:

Platform:

Replies:

131334 Jul 5,2017 08:30 AM Jul 6,2017 11:47 AM ASP.NET Core 1
loading
Tags: Grid
nax123
Asked On July 5, 2017 08:30 AM

I am looking for a way to use filterbar and filter also NULL end empty values. There is EnableComplexBlankFilter() Method that 'It sets the value that indicates to perform the filter operation with empty, null and undefined values.' but I cant find any information about how it should be used?

Farveen Sulthana Thameeztheen Basha [Syncfusion]
Replied On July 6, 2017 11:47 AM

Hi Customer, 

Thanks for contacting syncfusion support. 

Filtering  “NULL and empty values”  by using EnableComplexBlankFilter() method only supports for Excel type of filtering. But we have achieved your requirement filtering null and empty values using “ filterBarTemplate” property.  In the “read” event of the Template column,  we have get the filtered value and stored it in filterObject. After that we have pushed the filterObject into the this.model.filterSettings.filterColumns property and updated the Grid with refreshContent() method. 

Please refer to the code example:- 

<script type="text/javascript"> 
        $(function () { 
              $("#Grid").ejGrid({ 
                dataSource:ej.DataManager(shipDetails), 
                allowPaging :true, 
                           columns: [ 
                          { 
                            field: "ShipName", width: 100, filterBarTemplate: { 
                                create: function (args) { 
                                    return "<input>" 
                                }, 
                                write: function (args) { 
                                    var data = ej.DataManager(shipDetails).executeLocal(new ej.Query().select("ShipName")); 
                                    args.element.ejAutocomplete({ width: "100%", dataSource: data, enableDistinct: true, focusOut:       ej.proxy(args.column.filterBarTemplate.read, this, args) }); 
                                }, 
                                read: function (args) { 
                                          var filterObject = { 
                                             value:  args.element.val(), 
                                             field:  "ShipName", 
                                             operator: (args.element.val() == ''|| args.element.val() == null)? "equal" : "startswith", 
                                             type: "string", 
                                             predicate: "and", 
                                          }; 
                                    this.model.filterSettings.filteredColumns.push(filterObject); 
                                   this.refreshContent(); 
                                }, 
                              }, 
                            }, 
                           { field: "ShipCity", headerText: "Ship City", width: 80 } 
 
                       ], 
              }); 
 
        }); 
       var shipDetails = [ 
          { ShipName: null, ShipCity: 'Brazil' }, 
          { ShipName: 'Ale', ShipCity: 'USA' }, 
          { ShipName: 'Ricardo Adocicados', ShipCity: 'Brazil' } 
       ]; 
   </script> 


Please refer to the sample and API link :-  http://jsplayground.syncfusion.com/aoeqapkf 


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

Regards, 

Farveen sulthana T 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;