2

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

Community
  • 1
  • 1
Saritha
  • 181
  • 17

1 Answers1

1

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

Thomas Broyer
  • 64,353
  • 7
  • 91
  • 164
  • I have created a custom header for celltable. This custom header has combination of Textbox and checkbox. When I am type something in the textbox header i am able to capture and everything is smooth. But when i am clicking on the checkbox header, where its giving its value as **on** whether i have checking and unchecking the checkbox. Actually i should get true/false values. Why I am getting **on**? How should i get the true/false values when check/unchecking the checkbox in the header? – Saritha Aug 24 '12 at 10:33
  • com.google.gwt.dom.client.InputElement class has isChecked() method with taht i am able to get the value. My issue is solved. – Saritha Aug 24 '12 at 10:56