SmartGwt:使用画布将按钮添加到列表网格时出现异常
我正在使用 smartgwt2.4 并且我有 listgrid,其中我使用 canvas 动态添加按钮。它工作正常,但出现异常。调用 ListGrid.setData(record) 时它会引发异常。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)
请帮助我出去了.....
这是显示我如何使用画布将按钮添加到网格中的代码..以及为listgrid和listGridField设置的所有属性.........................
lgfprimaryCompanyName = new ListGridField("pCompany", "主要公司"); 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);
I am using smartgwt2.4 and i have listgrid in which i am adding button dynamically using canvas.it is working fine but giving an exception.It fires exception when ListGrid.setData(record)is called.Stacktrace is as follows..
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)
Please help me out.....
This is the code showing how i am using canvas for adding button in to grid ..and all propeties set for listgrid and listGridField...............
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);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否使用 AutoFitData 并指定了特定宽度?我相信这些冲突的设置会给你带来这个错误。
are you using AutoFitData and also specifying a specific width? I believe those conflicting settings would give you this error.