jQWidgets Forums

jQuery UI Widgets Forums Grid custom column filtering

Tagged: ,

This topic contains 1 reply, has 2 voices, and was last updated by  Peter Stoev 12 years, 3 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • custom column filtering #16864

    dperry
    Participant

    I have a grid where one column is being passed a json object in the form

    'trial' : {
    'name': 'trial-123',
    'link': {
    'objectId': 'object-123',
    'value': 'link-text'
    }
    }

    I’m using a custom cellsrenderer function to use this object to build an anchor to link to another page. This is working fine.
    I also need to filter this column based on the value of the trial.name field, but with default filtering options, the json object appears to have toString() called on it before the filter text is checked, so basically unless the filter starts with “[Object object]”, the filter check always fails.

    The best I can do to apply this custom filtering is to bind to the ‘filter’ event, clear the non-working filter, and then manually build up a filter to be applied again:

    var filtergroup = new $.jqx.filter();
    var filtertype = 'custom';
    var trialFilter = function(filterValue, cellValue, condition ) {
    console.log('in custom filter');
    return cellValue.name.toUpperCase().indexOf(filterValue.toUpperCase()) == 0;
    }
    var filter = filtergroup.createfilter(filtertype, filterText, 'starts_with', trialFilter);
    filtergroup.addfilter(1, filter);
    gridElement.jqxGrid('addfilter', 'trial', filtergroup, trialFilter);

    This obviously is super inefficient. How can I properly add custom filtering to a column whose column data is a json object?

    Thanks,
    -Dan

    custom column filtering #16938

    Peter Stoev
    Keymaster

    Hi dan,

    Unfortunately, your scenario is not supported. The built-in filtering works for “string”, “date”, “number” and “bool” data.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.