On Friday, April 13, 2012 7:16:10 PM UTC+2, Alfredo Quiroga-Villamil wrote:
>
> Scenario is as follows:
>
> - CellTable with a column containing an EditTextCell.
> - Add new record to the ListDataProvider.
> - I can edit and do all the good stuff by hand to the newly added record
> in the CellTable.
>
> Requirement:
>
> - Programmatically call a starttEdit on say the first cell of the newly
> created row/record.
>
> My investigation results:
>
> After going through the code and investigating, all roads seem to point to
> ViewData in EditTextCell. Specifically, ViewData in EditTextCell has
> setEditing(boolean) which should do the trick. However, ViewData has
> package access.
>
> Before I go and start to override, copy/paste things to be able to access
> the ViewData member I need, I figured I ask first since this seems like a
> basic operation when adding new records to a CellTable. I am thinking that
> I am very likely missing something.
>
IMO, you should:
1. extend the cell to automatically switch to an isEditing() state on
some trigger
2. share something from your presenter/view/whatever with the cell to
tell it which value/index to "auto-edit"
3. trigger a redraw of the table, to trigger the auto-edit in the Cell
(this will probably be your setRowData that adds the new "record")
To access the ViewData class, the easiest is to use JSNI, which allows
bypassing access checks. For instance, when the "auto-edit" is triggered in
your overridden render() method, to create the ViewData (before calling
setViewData(context.getKey(), viewData) and then super.render()), use:
private native Object createViewData(String text) /*-{
return
@com.google.gwt.cell.client.EditTextCell::new(Ljava/lang/String;)(text);
}-*/;
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-web-toolkit/-/BUF4Zk_6K7cJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.