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
close icon

Undefined generated in search query using Grid

using the grid , and webapi and webapi adapter, I tried to search and the following query was generated
which failed on getting into the webapi controller 
  1. Request URL:
    https://localhost:44305/api/Orders/?$inlinecount=allpages&$filter=(undefined(null,undefined))%20or%20(substringof(%27jj%27,tolower(cast(Id,%20%27Edm.String%27))))%20or%20(substringof(%27jj%27,tolower(cast(IdForeign,%20%27Edm.String%27))))%20or%20(substringof(%27jj%27,tolower(cast(Name,%20%27Edm.String%27))))%20or%20(substringof(%27jj%27,tolower(cast(Done,%20%27Edm.String%27))))%20or%20(undefined(null,undefined))&$orderby=Done&$skip=0&$top=12

  2. Any way to prevent query from including undefined , like just leaving it out , or what can i do different to fix this. Thank you

1 Reply

TS Thavasianand Sankaranarayanan Syncfusion Team February 12, 2019 09:15 AM UTC

Hi Samuel, 

Greetings from Syncfusion. 

We have analyzed your query. We could see that the “undefined” values shown in “RawValue” is for the “checkbox” column, since the field property will not be provided for the “checkbox” column, its showing as undefined. We suggest you to push only the columns to the “searchSettings.field” property to avoid undefined in query(only the columns in “searchSettings.field” will be included during searching). Please refer the code below, 

 
<script> 
    var grid = new ej.grids.Grid({ 
        dataSource: new ej.data.DataManager({ 
            url: "/api/Values", 
            adaptor: new ej.data.WebApiAdaptor(), 
            crossDomain: true 
        }), 
        ... 
        actionBegin:function(args){ 
            if (args.requestType == "searching") { 
                for (var i = 0; i < this.getColumns().length; i++) { 
                    if (this.getColumns()[i].field) { 
                        this.searchSettings.fields.push(this.getColumns()[i].field)    //These columns fields will only be included in searching. So  
                    } 
                } 
            } 
        }, 
        ... 
    }); 
    grid.appendTo("#Grid"); 
</script> 


Documentations :  
 
We have prepared a sample based on this scenario to perform searching in Grid when bound data with “WebApiAdaptor”. We are attaching the sample for your convenience. Please download the sample from the link below, 

We would also like to suggest you to refer to the “controller” code section of the below KB link, in which we have included the code to perform server side “searching” when using Web API service. 
 
Please get back to us if you need further assistance. 

Regards, 
Thavasianand S. 


Loader.
Live Chat Icon For mobile
Up arrow icon