private void addFilter(final String pid) {

    HeaderCell cell = filterRow.getCell(pid);
    TextField filterField = new TextField();
    filterField.addStyleName(ValoTheme.TEXTFIELD_TINY);
    filterField.setInputPrompt("Filter");
    filterField.setWidth("100px");

    @SuppressWarnings("unchecked")
    final BeanItemContainer<EventThreatBean> container =
        (BeanItemContainer<EventThreatBean>) getContainerDataSource();

    filterField.addTextChangeListener(
        new TextChangeListener() {

          private static final long serialVersionUID = 1L;

          @Override
          public void textChange(final TextChangeEvent event) {

            container.removeContainerFilters(pid);

            System.out.println(event.getText());

            if (!event.getText().isEmpty()) {

              container.addContainerFilter(
                  new SimpleStringFilter(pid, event.getText(), true, false));
            }

            setCaption("Total events " + container.size());
          }
        });

    cell.setComponent(filterField);
  }
  private void buildGrid() {

    // disable and change for ES Search

    Query query =
        this.buildESQuery(
            PerisaiUtil.convertDateToString(today, dtFormat),
            PerisaiUtil.convertDateToString(tmrw, dtFormat));
    List<EventThreatBean> list = this.getThreatsFromES(query);

    /*
    List<EventThreatBean> list = PerisaikonsolUI.getEventsDataProvider()
    		.getThreatEvents(PerisaiUtil.convertDateToString(today, dtFormat),
    				PerisaiUtil.convertDateToString(tmrw, dtFormat),groups);*/

    System.out.println("Total Events " + list.size());

    final BeanItemContainer<EventThreatBean> ds =
        new BeanItemContainer<EventThreatBean>(EventThreatBean.class, list);
    setCaption("Total events " + list.size());
    setContainerDataSource(ds);
    setImmediate(true);

    /*if(list.size()<7){
    	this.setHeightMode(HeightMode.ROW);
    	this.setHeightByRows(list.size());
    }*/

    setSizeFull();
    filterRow = appendHeaderRow();

    HeaderCell dateCell = filterRow.getCell("created");
    dateCell.setComponent(buildDateFilter());

    removeColumn("clientId");
    removeColumn("threatId");
    removeColumn("scanCode");

    setFrozenColumnCount(4);

    styleHeaders();

    setColumnOrder(
        "groupName",
        "clientName",
        "userName",
        "perisaiVersion",
        "created",
        "threatName",
        "fileName",
        "threatType",
        "threatLevel",
        "threatOperatingSystem",
        "actionTaken",
        "threatDescription");
    this.getColumn("fileName").setWidth(300);
    this.getColumn("threatDescription").setWidth(500);

    footer = appendFooterRow();
    footer.join(
        "groupName",
        "clientName",
        "userName",
        "perisaiVersion",
        "created",
        "threatName",
        "threatDescription",
        "fileName",
        "threatType",
        "threatLevel",
        "threatOperatingSystem",
        "actionTaken");

    // this.getColumn("created").setHeaderCaption("Event Date");

    buildFilters();

    buildFooterButtons();
  }