Celltable with customheader with filter textbox into it(how to bind the filter textbox to keyUphandler

StackOverflow https://stackoverflow.com/questions/12071072

  •  27-06-2021
  •  | 
  •  

Question

I have a requirement where i need to create the custom header which has textbox. When typing in it need to filter for the matching records.

By using following link ,I have created custom header. My CustomHeader class is

final public class ColumnHeaderFilterCell extends AbstractCell<String> {

interface Templates extends SafeHtmlTemplates {
@SafeHtmlTemplates.Template("<div >{0}</div>")
SafeHtml text(String value);

@SafeHtmlTemplates.Template("<div >
<input type=\"text\" value=\"\" name=\"{0}\"/></div>")
SafeHtml filter(String value);
}

private static Templates templates = GWT.create(Templates.class);

@Override
public void render(Context context, String value, SafeHtmlBuilder sb) {
if (value == null) {
    return;
}

SafeHtml renderedText = templates.text(value);

sb.append(renderedText);

SafeHtml renderedFilter = templates.filter(value);
sb.append(renderedFilter);
}
}

*ColumnHeader class is* 


public static class ColumnHeader extends Header<String> {

private String name_;

public ColumnHeader(String name) {
    super(new ColumnHeaderFilterCell());
    this.name_ = name;
    //setHeaderStyleNames("columnHeader " + field);
}

@Override
public String getValue() {
    return name_;
}
}

*Adding a column as*

ColumnHeader docColHeader = new ColumnHeader("Documentaton");
cellTable.addColumn(documentaton, docColHeader);

Now my question is how can i add the addKeyUpHandler() event to the textbox which is celltable header?

I have implemented the filtering on celltable if the textbox outside somewhere else by using following link If iam able to pass the textbox object to the celltable header may be its helpful. i don't know how to pass.

Can anyone please help me

Was it helpful?

Solution

Event handling within cells is not done through event handlers like with widgets, but at a lower level. See https://developers.google.com/web-toolkit/doc/latest/DevGuideUiCustomCells#cell-onBrowserEvent

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top