EasyUI Forum
April 23, 2024, 04:39:35 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: [Solved]any way to override the filter match so it applies to the rendered cell?  (Read 5765 times)
chrwei
Full Member
***
Posts: 219


View Profile Email
« on: September 13, 2019, 01:12:23 PM »

I have formatted date cell in a DataGrid, and the filter is applying as a string match on the date object in my data instead of the formatted output.

example:  data has 2019-04-10T00:00:00.000Z, cell show 4/10/2019.  a search for 4/10 has no results, but 4-10 does.

« Last Edit: September 20, 2019, 06:35:03 AM by chrwei » Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #1 on: September 14, 2019, 12:43:08 AM »

The simplest way is to convert the date to formatted string before loading to the DataGrid. Another way to solve this issue is to extend a date operator and apply it to the column.
Code:
const extOperators = Object.assign(filterOperators, {
  dcontains: {
    text: 'DateContains',
    isMatch: function (source, value) {
      source = String(source);
      value = String(value);
      ...
      //return source.toLowerCase().indexOf(value.toLowerCase()) >= 0;
    }
  }
})
Code:
<GridColumn field="date" title="Date" defaultFilterOperator="dcontains"
/>
Logged
chrwei
Full Member
***
Posts: 219


View Profile Email
« Reply #2 on: September 16, 2019, 07:58:06 AM »

what does extOperators get assigned to?   this is the part that's not clear to me, how do I get those operators into the scope of the grid and column?  docs are completely missing on this.
Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #3 on: September 16, 2019, 06:45:31 PM »

Set the DataGrid component with 'filterOperators' property set to this 'extOperators'. The DataGrid component has all the properties that are extended from ListBase component.
Logged
chrwei
Full Member
***
Posts: 219


View Profile Email
« Reply #4 on: September 19, 2019, 12:08:47 PM »

after some guessing, the scope clue I was looking for is:  import { filterOperators } from 'rc-easyui'
it was not clear that this was something that could be imported.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!