首页 > 解决方案 > 创建 GWT Material Design MaterialDataTable 导致抛出异常

问题描述

我正在尝试将数据表添加到我的页面,但无论我尝试什么,我都会不断抛出异常。

我的观点:

public class SessionsView extends ViewWithUiHandlers<ISessionsUiHandlers> implements SessionsPresenter.MyView {
interface Binder extends UiBinder<Widget, SessionsView> {
}

@UiField MaterialDataTable<SessionDTO> activeTable;

@Inject
SessionsView(Binder uiBinder) {
    initWidget(uiBinder.createAndBindUi(this));

}
}

我的 ui.xml:

<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
    xmlns:g='urn:import:com.google.gwt.user.client.ui'
    xmlns:m='urn:import:gwt.material.design.client.ui'
    xmlns:ma="urn:import:gwt.material.design.addins.client">

<ui:with field="tokens" type="ca.davidcarter.sessionmanager.client.place.NameTokens"/>

<m:MaterialPanel>
    <m:MaterialPanel ui:field="titlePanel" backgroundColor="BLUE_DARKEN_2" textColor="WHITE"  padding="10" paddingLeft="110" shadow="0">
        <m:MaterialRow marginBottom="0" >
            <m:MaterialColumn grid="s6">
                <m:MaterialLabel ui:field="title" text="Sessions" fontSize="2.3em"/>
            </m:MaterialColumn>
            <m:MaterialColumn textAlign="RIGHT" grid="s6">
                <m:MaterialLink ui:field="create" iconType="ADD_TO_PHOTOS" waves="DEFAULT" textColor="WHITE" />
            </m:MaterialColumn>
        </m:MaterialRow>
    </m:MaterialPanel>

    <m:MaterialRow>
        <m:table.MaterialDataTable ui:field="activeTable"
                                       shadow="1"
                                       rowHeight="60"
                                       height="calc(100vh - 131px)"
                                       useStickyHeader="true"
                                       useCategories="true"
                                       useRowExpansion="true"
                                       selectionType="SINGLE"/>
    </m:MaterialRow>
</m:MaterialPanel>

当我按原样运行它时,代码会引发异常,结果是空白显示。如果我注释掉表格(以及视图中的 UiField),一切正常。

使用 Firefox 调试器,我可以将其追溯到对 initWidget() 的调用。它抛出以下错误:

Paused on exception
TypeError: $wnd.$ is not a function

抛出错误的代码行在 gwt.material.design.client.ui.table.Table 中:

public Table(Element element) {
    super(element);

    this.element = JsTableElement.$(getElement());
}

具体来说,导致异常的是对 getElement() 的 Javascript 调用。

我已经尝试了所有我能想到的东西,但我不知道如何超越这一点。

建议?

标签: javascriptgwtgwt-material-design

解决方案


推荐阅读