jQuery UI Widgets Forums Angular Datafield Filtering

This topic contains 1 reply, has 2 voices, and was last updated by  svetoslav_borislavov 1 week, 3 days ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • Datafield Filtering #122270

    chuckm
    Participant

    Good afternoon,

    I have a grid where I’ve added extra datafields (without columns) and would like to know if it’s possible to filter on these datafields (that are not connected to columns)?

    I notice that the intellisense for the addfilter function states: addfilter( dataField: string, filterGroup: any, refreshGrid?: boolean): void
    Which gives the impression that the filter can indeed work off a datafield vs. a column.

    Please let me know if that’s possible. If not, I’d highly recommend adding this functionality as it’s helpful to be able to filter rows from a grid based on data that isn’t seen. If there’s a better way to perform this type of functionality, I’d greatly appreciate knowing.

    Thank you!
    Chuck

    Datafield Filtering #122275

    Hi,

    To apply a filter to a datafield you can create a column with this datafield and set the column property ‘hidden’ to true.
    This way you won’t have an extra column.

    
    dataSource = new jqx.dataAdapter({
        localData: this.data,
        dataFields: [
          { name: 'id', type: 'number' },
          { name: 'name', type: 'string' },
          { name: 'someProp', type: 'string' }
        ]
      });
    
    columns = [
      { text: 'Id', datafield: 'id', hidden: true },
      { text: 'Name', datafield: 'name' },
      { text: 'SomeProp', datafield: 'someProp' },
    ];
    
    ngAfterViewInit(): void {
      let filtergroup = new jqx.filter();
      let filtervalue = 5;
      let filtercondition = 'less_than';
    
      let filter1 = filtergroup.createfilter('numericfilter', filtervalue, filtercondition);
    
      this.grid.addfilter('id', filter1, true);
      this.grid.applyfilters();
    }
    

    Best regards,
    Svetoslav Borislavov

    jQWidgets Team
    https://www.jqwidgets.com/

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

You must be logged in to reply to this topic.