change default filterSettings columns operator

How can I set the default operator to "contains" instead of "equal"?

this.$refs.grid.ej2Instances.filterSettings.columns.operator = 'contains';

not work.

thanks!

3 Replies 1 reply marked as answer

RR Rajapandi Ravi Syncfusion Team November 4, 2020 11:59 AM UTC

Hi Murilo, 

Greetings from syncfusion support 

Query#: How can I set the default operator to "contains" instead of "equal"? 

We have analyzed your query and we could see that you like to change the default operator for the string columns as “contains” from “equal”. 

You can achieve your requirement by using the actionComplete event of the Grid. Please refer the below code example and sample for more information. 

<template> 
  <div id="app"> 
    <ejs-grid 
      :dataSource="data" 
      :allowFiltering="true" 
      :actionComplete="actionComplete" 
      :filterSettings="filterOptions" 
      height="273px" 
    > 
      <e-columns> 
. . . 
      </e-columns> 
    </ejs-grid> 
  </div> 
</template> 
<script> 
Vue.use(GridPlugin); 
 
export default { 
  data() { 
    return { 
      data: data, 
      filterOptions: { 
        type"Menu", 
      }, 
    }; 
  }, 
  methods: { 
    actionCompletefunction (args) { 
      if (args.columnType === "string") { 
        args.filterModel.flMuiObj.dropOptr.value = "contains"; 
      } 
    }, 
  }, 
  provide: { 
    grid: [Filter], 
  }, 
}; 
</script> 


You can also have the option to change the filter menu for particular column by using filter property. Refer to the below code example 


<template> 
  <div id="app"> 
    <ejs-grid 
      :dataSource="data" 
      :allowFiltering="true" 
      :actionComplete="actionComplete" 
      :filterSettings="filterOptions" 
      height="273px" 
    > 
      <e-columns> 
        <e-column 
          field="CustomerID" 
          :filter="colfilter" 
          headerText="Customer ID" 
          width="120" 
        ></e-column> 
            .  .  .  .  .  .  .  
            .  .  .  .  .  .  . 
      </e-columns> 
    </ejs-grid> 
  </div> 
</template> 
<script> 
import Vue from "vue"; 
import { GridPlugin, Filter } from "@syncfusion/ej2-vue-grids"; 
import { data } from "./datasource.js"; 
Vue.use(GridPlugin); 

export default { 
  data() { 
    return { 
      data: data, 
      colfilter: { operator: "contains" }, 
      filterOptions: { 
        type: "Menu", 
      }, 
    }; 
  }, 
  methods: { 
  }, 
  provide: { 
    grid: [Filter], 
  }, 
}; 
</script> 
<style> 
</style> 

Regards, 
Rajapandi R

Marked as answer

MU Murilo November 4, 2020 09:48 PM UTC

work fine!

thanks!


RR Rajapandi Ravi Syncfusion Team November 5, 2020 08:46 AM UTC

Hi Murilo, 
 
Thanks for the update 
 
We are happy to hear that our suggested solution was working fine from your end. 
 
Regards, 
Rajapandi R 
 


Loader.
Up arrow icon