Author Topic: Is there a 'listener' for MenuUI Filter  (Read 2139 times)

TonyLeech

  • Pro Enterprise
  • Jr. Member
  • *
  • Posts: 76
    • View Profile
Is there a 'listener' for MenuUI Filter
« on: August 25, 2020, 03:10:25 am »
I've been using the standard header filter for a long time with a listener to convert from a datepicker to a millisecond timestamp.

Code: [Select]
{ title: "Oldest Count", minWidth: 175, dataIndx: "oldestcount", align:"center", editable: false, dataType:"integer",
render: formatDate,
filter: { crules: [{condition: "between"}],
init: uiDatePicker,
listeners: [{ 'change': function(evt, ui) {
ui.value = millisecondsFromShortDate(ui.value);
ui.value2 = millisecondsFromShortDate(ui.value2);
$(evt.target).closest(".pq-grid").pqGrid('filter', {
oper: "add",
rules: [ui]
})
}}]
}
}

When I use the datepicker in the MenuUI filter the colModel filter listener does not trigger.  Is there a listener for the MenuUI filter?  Alternatively, can you advise how I can intercept the MenuUI filter to convert the datepicker into a millisecond timestamp before the remote request is triggered by the filter?

Thanks in advance.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6173
    • View Profile
Re: Is there a 'listener' for MenuUI Filter
« Reply #1 on: August 25, 2020, 06:04:57 am »
https://paramquery.com/pro/api#option-column-filter

It's a singular listener:

Code: [Select]
listener: function(evt, ui){

this.filter({
oper: "add",
rules: .....
});
}

TonyLeech

  • Pro Enterprise
  • Jr. Member
  • *
  • Posts: 76
    • View Profile
Re: Is there a 'listener' for MenuUI Filter
« Reply #2 on: August 25, 2020, 04:49:24 pm »
I changed it to single listener, but it doesn't trigger from the menuUI icon.

Code: [Select]
{ title: "Oldest Count", minWidth: 175, dataIndx: "oldestcount", align:"center", editable: false, dataType:"integer",
render: formatDate,
filter: { crules: [{condition: "between"}],
init: uiDatePicker,
listener: function(evt, ui) {
ui.value = millisecondsFromShortDate(ui.value);
ui.value2 = millisecondsFromShortDate(ui.value2);
this.filter({
oper: "add",
rules: [ui]
})
}
}
}

The original header filter box with datepicker works fine and triggers the listener, but using the filter build into the menuUI icon selects a date, but doesn't trigger the listener and so sends a raw date string rather than the millisecond timestamp that I should get from the listener.  I've included all the code for the column in colModel...should I be putting the filter listener somewhere else like inside filterModel?