import { ISetFilterParams } from "ag-grid-community";
import { Datacontext } from '../../data/data-context';
import { Container } from 'aurelia-framework';

export class RemoteSet /*extends SetFilter*/ {
  tableName: string;
  fieldName: string;
  datacontext: Datacontext;
  constructor() {
    //super();

    this.datacontext = Container.instance.get(Datacontext);
  }
  init(params: ISetFilterParams) {
    this.tableName = params.colDef.filterParams.tableName;
    this.fieldName = params.colDef.filterParams.fieldName;

    params.colDef.filterParams.values = (p) => {
      this.datacontext.getDistinctPropertyValues(this.tableName, this.fieldName, false).then((results: Array<any>) => {
        //this.setFilterValues(results);
        p.success(results);
      });
    }

    //super.init(params);    


  }

  getGui() {
    //return super.getGui();
  }
}
