ui-grid icon indicating copy to clipboard operation
ui-grid copied to clipboard

changing filter dynamically

Open gindij opened this issue 11 years ago • 2 comments

Hi,

I am trying to change the column filters dynamically. To do this, I have added menu items to the column menu of the form:

title: "contains", action: function() { newCol.filter = {condition: uiGridConstants.filter.CONTAINS, placeholder: 'contains'}}

When I select the contains item from the column menu, the placeholder changes in the filter input field, but it still only filters using the start with condition, which I set as the default (before the user chooses any of the dropdown options). Can anyone help me figure out why the condition of the filter input box isn't updating?

Thanks in advance

gindij avatar Jun 09 '15 16:06 gindij

What is newCol? Is it a gridCol, or is it a colDef? On the gridCol, you probably want to use filters[0] rather than filter.

It looks to me like you're replacing the filter object - you're assigning a new object { condition...., placeholder....} to it. If you instead do:

  newCol.filter.condition = uiGridConstants.filter.CONTAINS;
  newCol.filter.placeholder = 'contains';

Then you'll update the existing object, and it's more likely to work.

PaulL1 avatar Jun 09 '15 18:06 PaulL1

Answer given, no response for some months. Closing.

PaulL1 avatar Nov 18 '15 07:11 PaulL1