Thursday, September 4, 2014

Re: CellTable tab not working after change event

Exact same problem for me.  Any solution to this? (other than switch to GXT grids)

On Friday, October 19, 2012 4:33:04 AM UTC-5, Bhumika Thaker wrote:
I have implemented same things and I am facing same problem. Did you find any solution for it yet?

Tab is working fine in celltable, but when I am changing any value  in EditableTextCell  and then press tab, it will start from first cell.

Thanks in Advance


On Monday, 12 December 2011 21:43:58 UTC+5:30, sean tunlaw wrote:
From the CellTableExample in the API:

http://google-web-toolkit.googlecode.com/svn/javadoc/latest/index.html?overview-summary.html

 I customized it slightly to implement tab order.
However, tabbing  does not work because table.redraw in
nameColumn.setFieldUpdater steals focus away. If I don't edit the
field and just click on the
TextInputCell, tabbing works. If i comment out
the table.redraw, tabbing works after I have edited a field but my
other fields don't update.

After editing a field , a change event is fired in onBrowser method.
This eventually calls finishediting which then calls the update
method
in the column.fieldUpdater. In the update method is where the
table.redraw is located

I have also tried keeping my list of objects in the ListDataProvider
and calling ListDataProvider.refresh but I have the same issue.
Question) How can I implement tab order and allow tabbing after
editing but still be able to refresh the Celltable grid. I need to
redraw/ refresh the grid because after tabbing I need to update data
in the other columns.

The customization that i needed to do was :
1) Extend TextInputCell and override render methods so that I can set
a tabindex by customizing  template.input
(see below code)
2) In CellTableExample, I disabled KeyboardSelectionPolicy
table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);

==============  inheriting TextInputCell
=======================================

public class EditableTextCell extends TextInputCell {
         private static final Logger logger =
Logger.getLogger(EditableTextCell.class.getName());
  private SimpleTemplate template;
        protected SafeHtmlRenderer<String> renderer;
        private boolean inline;
    interface SimpleTemplate extends SafeHtmlTemplates {
                @Template("<input value=\"{0}\" tabindex=\"{1}\"></
input>")
                SafeHtml input( String value,int tabindex);
        }
    public EditableTextCell(EventBus eventBus,
                        SafeHtmlRenderer<String> renderer, boolean
inline) {
        super(renderer);
        this.renderer = renderer;
                template = GWT.create(SimpleTemplate.class);
        }
        public EditableTextCell() {
        }
        @Override
        public void render(Context context, String value,
SafeHtmlBuilder sb)
{
                Contact key = (Contact) context
                                .getKey();
                String name = key.getName();
                // Get the view data.
                ViewData viewData = getViewData(key);
                if (viewData != null &&
viewData.getCurrentValue().equals(value)) {
                        clearViewData(key);
                        viewData = null;
                }
                String s = (viewData != null) ?
viewData.getCurrentValue() : value;
                if (s != null   ) {
                        String style = "";
                        SafeHtml html = renderer.render(s);
                        // Note: template will not treat SafeHtml
specially
                        sb.append(template.input( html.asString(),
                                        key.getId() ));
                } else {
                        sb.appendHtmlConstant("<input type=\"text\"
tabindex=\"-1\"></
input>");
                }
        }
        @Override
        public void onBrowserEvent(Context context, Element parent,
String
value,
                      NativeEvent event, ValueUpdater<String>
valueUpdater){
            String eventType = event.getType();
                logger.fine("onBrowserEvent...   " + eventType);
            super.onBrowserEvent(context,parent, value,  event,
valueUpdater);
        }

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment