将 JS 包装到 GWT 单元格中 table

Wrapping JS into GWT cell table

在 GWT Cell Table 中,我正在使用 JSNI 包装 jquery 功能(如分组)。但它抛出 JavaScriptObject 异常(函数未定义)。我在加载数据后调用此 JSNI 方法一次

table.setRowData(loadContactInfo());  //To Load Data
    loadGridData();    //Calling JSNI For Grouping 

     private List<ContactInfor> loadContactInfo() {
            // To load data
    List<ContactInfor> lstContact = new ArrayList<ContactInfor>();

    lstContact.add(new ContactInfor("XXX", "YYY", "t", "26", "0300",Big Street"));
            return ContactInfor;
    }

    public static native void loadGridData()/*-{
       //calling js for grouping functionality which contains table tr element
     }-*/; 

由于它需要几毫秒来重绘单元格 table 在此之前调用 JSNI 方法抛出 JSO exception.Is 还有其他方法将 JS 包装到单元格中 table在数据加载和渲染之后?对此有何建议?

上面的代码中只有很少的信息,但是如果你的问题是因为重绘和 jquery 之间的时间问题,你可能需要使用 Scheduler.get().scheduleDeferred() 命令来在您再次更改 dom 之前让浏览器完成它的工作。

http://www.gwtproject.org/javadoc/latest/com/google/gwt/core/client/Scheduler.html

感谢您的回复,我在加载数据后使用了 "flush()" 语句,请参阅下面的代码

    table.setRowData(loadContactInfo());  
    **table.flush();    //flush force to render immediately**
    loadGridData();    

     private List<ContactInfor> loadContactInfo() {
            // To load data
    List<ContactInfor> lstContact = new ArrayList<ContactInfor>();

    lstContact.add(new ContactInfor("XXX", "YYY", "t", "26", "0300",Big Street"));
            return ContactInfor;
    }

    public static native void loadGridData()/*-{
       //calling js for grouping functionality which contains table tr element
     }-*/; 

也可以使用 Scheduler.get().scheduleDeferred() 来增加延迟。