我正在使用smartgwt2.4并且我有listgrid我在其中使用canvas动态添加按钮。它工作正常但是给出了异常。当调用ListGrid.setData(记录)时它会触发异常.Stacktrace如下所示。
com.smartgwt.client.core.JsObject$SGWT_WARN: 12:15:12.808:WARN:Button:isc_Button_0:ignoring bad or negative top: NaN [enable 'sizing' log for stack trace]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:105)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:157)
at com.google.gwt.dev.shell.BrowserChannel.reactToMessagesWhileWaitingForReturn(BrowserChannel.java:1713)
at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:165)
at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:120)
at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:507)
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeVoid(ModuleSpace.java:284)
at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeVoid(JavaScriptHost.java:107)
at com.smartgwt.client.widgets.BaseWidget.setProperty(BaseWidget.java)
at com.smartgwt.client.widgets.BaseWidget.setAttribute(BaseWidget.java:628)
at com.smartgwt.client.widgets.grid.ListGrid.setData(ListGrid.java:9621)
at com.prolinkdpocadmin.client.widgets.DeduplicationContentGrid.fillGridFromJson(DeduplicationContentGrid.java:213)
at com.prolinkdpocadmin.client.widgets.DeduplicationContainer.setDataInGrid(DeduplicationContainer.java:104)
at com.prolinkdpocadmin.client.widgets.DeduplicationContainer.access$0(DeduplicationContainer.java:101)
at com.prolinkdpocadmin.client.widgets.DeduplicationContainer$1.onSuccess(DeduplicationContainer.java:46)
at com.prolinkdpocadmin.client.widgets.DeduplicationContainer$1.onSuccess(DeduplicationContainer.java:1)
at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:216)
at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:287)
at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:393)
at sun.reflect.GeneratedMethodAccessor15.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:157)
at com.google.gwt.dev.shell.BrowserChannel.reactToMessagesWhileWaitingForReturn(BrowserChannel.java:1713)
at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:165)
at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:120)
at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:507)
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:264)
at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:188)
at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:157)
at com.google.gwt.dev.shell.BrowserChannel.reactToMessages(BrowserChannel.java:1668)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:401)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:222)
at java.lang.Thread.run(Thread.java:662)
请帮帮我.....
这是显示我如何使用canvas将按钮添加到网格中的代码..以及为listgrid和listGridField设置的所有propeties ...............
lgfprimaryCompanyName = new ListGridField(“pCompany”,“Primary Company”); lgfprimaryCompanyName.setWidth(250); lgfprimaryCompanyName.setAlign(Alignment.LEFT);
lgfmarkPrimaryAsDuplicate = new ListGridField("MarkPrimaryDuplicate", "Mark As Duplicate");
lgfmarkPrimaryAsDuplicate.setWidth(130);
lgfmarkPrimaryAsDuplicate.setCanSort(false);
lgfmarkPrimaryAsDuplicate.setAlign(Alignment.CENTER);
// lgfmarkPrimaryAsDuplicate.addRecordClickHandler(this);
lgfduplicateCompanyName = new ListGridField("dCompany", "Duplicate Company");
lgfduplicateCompanyName.setWidth(250);
lgfduplicateCompanyName.setAlign(Alignment.LEFT);
lgfmarkDuplicateAsDuplicate = new ListGridField("MarkDuplicateDuplicate", "Mark as Duplicate");
lgfmarkDuplicateAsDuplicate.setWidth(130);
lgfmarkDuplicateAsDuplicate.setCanSort(false);
lgfmarkDuplicateAsDuplicate.setAlign(Alignment.CENTER);
// lgfmarkDuplicateAsDuplicate.addRecordClickHandler(this);
lgDuplicateCompany = new ListGrid() {
@Override
protected Canvas createRecordComponent(final ListGridRecord record, Integer colNum) {
String fieldName = this.getFieldName(colNum);
if (fieldName.equals("MarkPrimaryDuplicate")) {
Button btnMarkPrimaryAsDuplicate = new Button();
btnMarkPrimaryAsDuplicate.setTitle("" + record.getAttribute("MarkPrimaryDuplicate"));
btnMarkPrimaryAsDuplicate.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
Window.alert("button in column 2 is clicked");
}
}
}
});
return btnMarkPrimaryAsDuplicate;
} else if (fieldName.equals("MarkDuplicateDuplicate")) {
Button btnMarkDuplicateAsDuplicate = new Button();
btnMarkDuplicateAsDuplicate.setTitle("" + record.getAttribute("MarkDuplicateDuplicate"));
btnMarkDuplicateAsDuplicate.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
Window.alert("button in column 4 is clicked");
}
});
return btnMarkDuplicateAsDuplicate;
} else {
return null;
}
}
};
lgDuplicateCompany.setFields(lgfprimaryCompanyName, lgfmarkPrimaryAsDuplicate, lgfduplicateCompanyName, lgfmarkDuplicateAsDuplicate);
lgDuplicateCompany.setWidth(780);
lgDuplicateCompany.setSelectionType(SelectionStyle.SINGLE);
lgDuplicateCompany.setSelectionAppearance(SelectionAppearance.ROW_STYLE);
lgDuplicateCompany.setCanResizeFields(true);
lgDuplicateCompany.setCanReorderFields(true);
lgDuplicateCompany.setShowRecordComponents(true);
lgDuplicateCompany.setShowRecordComponentsByCell(true);
答案 0 :(得分:0)
您使用的是AutoFitData还是指定了特定的宽度?我相信那些有冲突的设置会给你这个错误。