Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Accessing ListGridRecord from ComboBox

    I have combobox which is mapped to DataSource and I can display data obtained from the server. I can easily access value and display field when user select some item.

    However, I would like to access some other data from selected item which I can get from ListGridRecord. Is it possible to access selected ListGridRecord in combo box? I can use selected value to filter underlying DataSource and get ListGridRecord but is there more elegant way?

    #2
    oups it seems that your question is the same that the one i have just posted.
    Sorry for the doublons Isomorphic

    Regards

    Comment


      #3
      Hi Guys,

      SmartGWT is missing ComboBoxItem.getSelectedRecord() - we'll add this - you can call it via JSNI right now if necessary.

      Comment


        #4
        thank you Iso ;)

        Regards

        Comment


          #5
          Hm, I was looking for such method in SmartClient and I don't know how I missed it! :)
          Probably because I expected ListGridRecord as result type instead of Object. I guess I can cast it to ListGridRecord, right?

          Comment


            #6
            If someone needs this functionality, here is the code I use in subclass of ComboBoxItem.

            Code:
                public native ListGridRecord getSelectedRecord() /*-{
            	    var self = this.@com.smartgwt.client.core.DataClass::getJsObj()();
            	    var ret = self.getSelectedRecord();
            	    if(ret == null || ret === undefined) return null;
            	    var retVal = @com.smartgwt.client.core.RefDataClass::getRef(Lcom/google/gwt/core/client/JavaScriptObject;)(ret);
            	    if(retVal == null) {
            	        retVal = @com.smartgwt.client.widgets.grid.ListGridRecord::new(Lcom/google/gwt/core/client/JavaScriptObject;)(ret);
            	    }
            	    return retVal;
            	}-*/;

            Comment


              #7
              Thanks for posting that dejan! We'll let you know when getSelectedRecord() lands in SVN.

              Comment


                #8
                Hi,
                i encoutered the same problem, but getSelectedRecord() method into a child of CheckBoxItem does not work.
                That did i miss.

                Here the code i used:


                public class ComboBoxItemBC extends ComboBoxItem {

                public ComboBoxItemBC(String ch)
                {
                super(ch);
                }

                public native ListGridRecord getSelectedRecord() /*-{
                var self = this.@com.smartgwt.client.core.DataClass::getJsObj()();
                var ret = self.getSelectedRecord();
                if(ret == null || ret === undefined) return null;
                var retVal = @com.smartgwt.client.core.RefDataClass::getRef(Lcom/google/gwt/core/client/JavaScriptObject;)(ret);
                if(retVal == null) {
                retVal = @com.smartgwt.client.widgets.grid.ListGridRecord::new(Lcom/google/gwt/core/client/JavaScriptObject;)(ret);
                }
                return retVal;
                }-*/;
                }

                Comment


                  #9
                  @derferic Not sure you understand what this thread is about. This is a ComboBoxItem loading records from a related DataSource via the optionDataSource functionality. There is no analogy to CheckBoxItem.

                  Comment


                    #10
                    Excuse me, for my bad explanation, effectively i use a ComboBoxItem (not a checkboxitem.. :) ) set via a datasource.
                    I need to retrieve the attached Record from the selected value.

                    After i picked up the value the returned selected record is alway null for me.

                    Thank

                    Comment


                      #11
                      Exception calling getSelectedRecord

                      Hi,
                      I still have problem calling combobox.getSelectedRecord with last nightly build installed (495 13-May-2009 04:01).
                      My ComboBoxItem is bound with an optional data source and used as EditorType for a ListGridField that share the same optional data source, derived from a GwtRpcDataSource, with a custom ListGridRecord.
                      When I try to get the selected record in the ChangeHandler of ComboBoxItem or in EditorExitHandler of the ListGridField, the following exception is raised (in hosted mode IE + Windows Vista):

                      Code:
                      (TypeError): Proprietà o metodo non supportati dall'oggetto
                       number: -2146827850
                      or the following in FireFox + Windows Vista:

                      Code:
                      (TypeError): c.getSelectedRecord is not a function fileName: http://localhost:8888/com.mytest.test.Main/629F299C3612FD82C8C9569073E035EB.cache.html lineNumber: 1436 stack: sTc([object Object])
                      @http://localhost:8888/com.mytest.test.Main/629F299C3612FD82C8C9569073E035EB.cache.html:1436 vqc([object Object],[object Object])
                      @http://localhost:8888/com.mytest.test.Main/629F299C3612FD82C8C9569073E035EB.cache.html:637 oei([object Object])
                      @http://localhost:8888/com.mytest.test.Main/629F299C3612FD82C8C9569073E035EB.cache.html:6450 hSf([object Object],[object Object],false)
                      @http://localhost:8888/com.mytest.test.Main/629F299C3612FD82C8C9569073E035EB.cache.html:4376 sSf([object Object],[object Object])
                      @http://localhost:8888/com.mytest.test.Main/629F299C3612FD82C8C9569073E035EB.cache.html:4367 Dah([object Object])
                      @http://localhost:8888/com.mytest.test.Main/629F299C3612FD82C8C9569073E035EB.cache.html:236 ([object Object],[object Object],"I","C")
                      @http://localhost:8888/com.mytest.test.Main/629F299C3612FD82C8C9569073E035EB.cache.html:290 ("I","C")
                      @http://localhost:8888/com.mytest.test.Main/sc/modules/ISC_Forms.js:1106 (null,"handleChange")
                      @http://localhost:8888/com.mytest.test.Main/sc/modules/ISC_Core.js:246 ("handleChange",[object Object])
                      @http://localhost:8888/com.mytest.test.Main/sc/modules/ISC_Core.js:238 ("I","C")
                      @http://localhost:8888/com.mytest.test.Main/sc/modules/ISC_Forms.js:1997 ("I")
                      @http://localhost:8888/com.mytest.test.Main/sc/modules/ISC_Forms.js:1045 ()
                      @http://localhost:8888/com.mytest.test.Main/sc/modules/ISC_Forms.js:1042 ("I")
                      @http://localhost:8888/com.mytest.test.Main/sc/modules/ISC_Forms.js:2005 ([object Object])
                      @http://localhost:8888/com.mytest.test.Main/sc/modules/ISC_Forms.js:1500 ([object Object],[object Object],1,[object Object],0,"Informazioni","Informazioni")
                      @http://localhost:8888/com.mytest.test.Main/sc/modules/ISC_Forms.js:186 ([object Object],1,0)
                      Debugging the code I can see the native function in ComboBoxItem.class explained in this thread.

                      Any suggestion?

                      Thanks in advance,
                      falco

                      Comment


                        #12
                        stack trace of failing getSelectedRecord

                        Here is StackTrace of above exception in hosted mode

                        Code:
                        com.google.gwt.core.client.JavaScriptException: (TypeError): Proprietà o metodo non supportati dall'oggetto
                         number: -2146827850
                         description: Proprietà o metodo non supportati dall'oggetto
                        	at com.google.gwt.dev.shell.JavaScriptHost.exceptionCaught(JavaScriptHost.java:27)
                        	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                        	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                        	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.ie.IDispatchImpl.callMethod(IDispatchImpl.java:126)
                        	at com.google.gwt.dev.shell.ie.IDispatchProxy.invoke(IDispatchProxy.java:155)
                        	at com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke(IDispatchImpl.java:294)
                        	at com.google.gwt.dev.shell.ie.IDispatchImpl.method6(IDispatchImpl.java:194)
                        	at org.eclipse.swt.internal.ole.win32.COMObject.callback6(COMObject.java:117)
                        	at org.eclipse.swt.internal.ole.win32.COM.VtblCall(Native Method)
                        	at org.eclipse.swt.internal.ole.win32.IDispatch.Invoke(IDispatch.java:64)
                        	at org.eclipse.swt.ole.win32.OleAutomation.invoke(OleAutomation.java:493)
                        	at org.eclipse.swt.ole.win32.OleAutomation.invoke(OleAutomation.java:417)
                        	at com.google.gwt.dev.shell.ie.ModuleSpaceIE6.doInvokeOnWindow(ModuleSpaceIE6.java:67)
                        	at com.google.gwt.dev.shell.ie.ModuleSpaceIE6.doInvoke(ModuleSpaceIE6.java:152)
                        	at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:447)
                        	at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:228)
                        	at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
                        	at com.smartgwt.client.widgets.form.fields.ComboBoxItem.getSelectedRecord(ComboBoxItem.java)
                        	at com.digitalage.ssb.client.widgets.SSBComboBox.getSelectedRecord(SSBComboBox.java:50)
                        	at com.digitalage.ssb.client.datapanel.VociBudgetEDPanel$2.onChange(VociBudgetEDPanel.java:184)
                        	at com.smartgwt.client.widgets.form.fields.events.ChangeEvent.dispatch(ChangeEvent.java:97)
                        	at com.smartgwt.client.widgets.form.fields.events.ChangeEvent.dispatch(ChangeEvent.java:1)
                        	at com.google.gwt.event.shared.HandlerManager$HandlerRegistry.fireEvent(HandlerManager.java:65)
                        	at com.google.gwt.event.shared.HandlerManager$HandlerRegistry.access$1(HandlerManager.java:53)
                        	at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:178)
                        	at com.smartgwt.client.core.DataClass.fireEvent(DataClass.java:190)
                        	at sun.reflect.GeneratedMethodAccessor35.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.ie.IDispatchImpl.callMethod(IDispatchImpl.java:126)
                        	at com.google.gwt.dev.shell.ie.IDispatchProxy.invoke(IDispatchProxy.java:155)
                        	at com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke(IDispatchImpl.java:294)
                        	at com.google.gwt.dev.shell.ie.IDispatchImpl.method6(IDispatchImpl.java:194)
                        	at org.eclipse.swt.internal.ole.win32.COMObject.callback6(COMObject.java:117)
                        	at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
                        	at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1925)
                        	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2966)
                        	at com.google.gwt.dev.GWTShell.pumpEventLoop(GWTShell.java:720)
                        	at com.google.gwt.dev.GWTShell.run(GWTShell.java:593)
                        	at com.google.gwt.dev.GWTShell.main(GWTShell.java:357)
                        com.google.gwt.core.client.JavaScriptException: (TypeError): Proprietà o metodo non supportati dall'oggetto
                         number: -2146827850
                         description: Proprietà o metodo non supportati dall'oggetto
                        	at com.google.gwt.dev.shell.JavaScriptHost.exceptionCaught(JavaScriptHost.java:27)
                        	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                        	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                        	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.ie.IDispatchImpl.callMethod(IDispatchImpl.java:126)
                        	at com.google.gwt.dev.shell.ie.IDispatchProxy.invoke(IDispatchProxy.java:155)
                        	at com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke(IDispatchImpl.java:294)
                        	at com.google.gwt.dev.shell.ie.IDispatchImpl.method6(IDispatchImpl.java:194)
                        	at org.eclipse.swt.internal.ole.win32.COMObject.callback6(COMObject.java:117)
                        	at org.eclipse.swt.internal.ole.win32.COM.VtblCall(Native Method)
                        	at org.eclipse.swt.internal.ole.win32.IDispatch.Invoke(IDispatch.java:64)
                        	at org.eclipse.swt.ole.win32.OleAutomation.invoke(OleAutomation.java:493)
                        	at org.eclipse.swt.ole.win32.OleAutomation.invoke(OleAutomation.java:417)
                        	at com.google.gwt.dev.shell.ie.ModuleSpaceIE6.doInvokeOnWindow(ModuleSpaceIE6.java:67)
                        	at com.google.gwt.dev.shell.ie.ModuleSpaceIE6.doInvoke(ModuleSpaceIE6.java:152)
                        	at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:447)
                        	at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:228)
                        	at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
                        	at com.smartgwt.client.widgets.form.fields.ComboBoxItem.getSelectedRecord(ComboBoxItem.java)
                        	at com.digitalage.ssb.client.widgets.SSBComboBox.getSelectedRecord(SSBComboBox.java:50)
                        	at com.digitalage.ssb.client.datapanel.VociBudgetEDPanel$2.onChange(VociBudgetEDPanel.java:184)
                        	at com.smartgwt.client.widgets.form.fields.events.ChangeEvent.dispatch(ChangeEvent.java:97)
                        	at com.smartgwt.client.widgets.form.fields.events.ChangeEvent.dispatch(ChangeEvent.java:1)
                        	at com.google.gwt.event.shared.HandlerManager$HandlerRegistry.fireEvent(HandlerManager.java:65)
                        	at com.google.gwt.event.shared.HandlerManager$HandlerRegistry.access$1(HandlerManager.java:53)
                        	at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:178)
                        	at com.smartgwt.client.core.DataClass.fireEvent(DataClass.java:190)
                        	at sun.reflect.GeneratedMethodAccessor35.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.ie.IDispatchImpl.callMethod(IDispatchImpl.java:126)
                        	at com.google.gwt.dev.shell.ie.IDispatchProxy.invoke(IDispatchProxy.java:155)
                        	at com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke(IDispatchImpl.java:294)
                        	at com.google.gwt.dev.shell.ie.IDispatchImpl.method6(IDispatchImpl.java:194)
                        	at org.eclipse.swt.internal.ole.win32.COMObject.callback6(COMObject.java:117)
                        	at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
                        	at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1925)
                        	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2966)
                        	at com.google.gwt.dev.GWTShell.pumpEventLoop(GWTShell.java:720)
                        	at com.google.gwt.dev.GWTShell.run(GWTShell.java:593)
                        	at com.google.gwt.dev.GWTShell.main(GWTShell.java:357)

                        Comment


                          #13
                          For a JavaScript Exception, hosted mode stack traces aren't helpful. Can you get a stack trace from the SmartClient Developer Console in IE?

                          Comment


                            #14
                            Developer Console and IE

                            Unfortunately running in IE caused the following error during tab opening

                            Code:
                            00:48:48.209:WARN:drawing:isc_OID_0:draw() called on widget with current drawn state: complete, use redraw() instead.
                                Canvas.readyToDraw()
                                Canvas.draw(_1=>undef)
                            
                            00:48:48.310:WARN:Log:Error:
                            	''pane' è nullo o non è un oggetto'
                            	in http://localhost:8888/com.digitalage.ssb.MainSSB/MainSSB.html
                            	at line 271
                                TabSet.removeTabs(_1=>Array[1], _2=>undef)
                                TabSet.removeTab(_1=>"VociBudgetEDPanellista", _2=>undef)
                                    "return this.removeTabs(_1,_2)"
                            
                            Global Log Priorities updated: Logging messages at priority 'Debug' and above for category 'ResultTree'.
                            00:50:45.865:WARN:drawing:isc_OID_0:draw() called on widget with current drawn state: complete, use redraw() instead.
                                Canvas.readyToDraw()
                                Canvas.draw(_1=>undef)
                            
                            00:50:46.014:WARN:Log:Error:
                            	''pane' è nullo o non è un oggetto'
                            	in http://localhost:8888/com.digitalage.ssb.MainSSB/MainSSB.html
                            	at line 271
                                TabSet.removeTabs(_1=>Array[1], _2=>undef)
                                TabSet.removeTab(_1=>"VociBudgetEDPanelgestione", _2=>undef)
                                    "return this.removeTabs(_1,_2)"
                            In Firefox the same step is working fine.

                            I will try to workaround this error to get the combobox exception instead.

                            TIA

                            falco

                            Comment


                              #15
                              Log from Developer Console

                              Firefox:
                              Code:
                              01:48:44.868:TMR8:WARN:Log:findByKeys: dataSource 'isc_OID_18' does not have primary keys declared, can't find record
                              01:48:45.386:TMR0:WARN:Log:TypeError: this.formItem is undefined
                              01:49:41.148:WARN:Log:com.google.gwt.core.client.JavaScriptException: (TypeError): c.getSelectedRecord is not a function
                               fileName: http://localhost:8888/com.digitalage.ssb.MainSSB/877DE4B21003EB0F9D88F37DD8579BC6.cache.html
                               lineNumber: 1433
                               stack: Cci([object Object])@http://localhost:8888/com.digitalage.ssb.MainSSB/877DE4B21003EB0F9D88F37DD8579BC6.cache.html:1433
                              Dqc([object Object],[object Object])@http://localhost:8888/com.digitalage.ssb.MainSSB/877DE4B21003EB0F9D88F37DD8579BC6.cache.html:640
                              afi([object Object])@http://localhost:8888/com.digitalage.ssb.MainSSB/877DE4B21003EB0F9D88F37DD8579BC6.cache.html:6458
                              oSf([object Object],[object Object],false)@http://localhost:8888/com.digitalage.ssb.MainSSB/877DE4B21003EB0F9D88F37DD8579BC6.cache.html:4379
                              zSf([object Object],[object Object])@http://localhost:8888/com.digitalage.ssb.MainSSB/877DE4B21003EB0F9D88F37DD8579BC6.cache.html:4370
                              gbh([object Object])@http://localhost:8888/com.digitalage.ssb.MainSSB/877DE4B21003EB0F9D88F37DD8579BC6.cache.html:237
                              ([object Object],[object Object],"I","R")@http://localhost:8888/com.digitalage.ssb.MainSSB/877DE4B21003EB0F9D88F37DD8579BC6.cache.html:293
                              ("I","R")@http://localhost:8888/com.digitalage.ssb.MainSSB/sc/modules/ISC_Forms.js:1114
                              (null,"handleChange")@http://localhost:8888/com.digitalage.ssb.MainSSB/sc/modules/ISC_Core.js:246
                              ("handleChange",[object Object])@http://localhost:8888/com.digitalage.ssb.MainSSB/sc/modules/ISC_Core.js:238
                              ("I","R")@http://localhost:8888/com.digitalage.ssb.MainSSB/sc/modules/ISC_Forms.js:2004
                              ("I")@http://localhost:8888/com.digitalage.ssb.MainSSB/sc/modules/ISC_Forms.js:1053
                              ()@http://localhost:8888/com.digitalage.ssb.MainSSB/sc/modules/ISC_Forms.js:1050
                              ("I")@http://localhost:8888/com.digitalage.ssb.MainSSB/sc/modules/ISC_Forms.js:2012
                              ([object Object])@http://localhost:8888/com.digitalage.ssb.MainSSB/sc/modules/ISC_Forms.js:1508
                              ([object Object],[object Object],1,[object Object],0,"Informazioni","Informazioni")@http://localhost:8888/com.digitalage.ssb.MainSSB/sc/modules/ISC_Forms.js:193
                              ([object Object],1,0)@http://localhost:8888/com.digitalage.ssb.MainSSB/sc/modules/ISC_Grids.js:1125
                              anonymous([object Object],1,0)@http://localhost:8888/com.digitalage.ssb.MainSSB/sc/modules/ISC_Grids.js:757
                              (1,0)@http://localhost:8888/com.digitalage.ssb.MainSSB/sc/modules/ISC_Grids.js:640
                              ([object Object],(void 0))@http://localhost:8888/com.digitalage.ssb.MainSSB/sc/modules/ISC_Grids.js:639
                              ([object Object],(void 0))@http://localhost:8888/com.digitalage.ssb.MainSSB/sc/modules/ISC_Core.js:2797
                              ([object Object],"click")@http://localhost:8888/com.digitalage.ssb.MainSSB/sc/modules/ISC_Core.js:1342
                              ([object Object])@http://localhost:8888/com.digitalage.ssb.MainSSB/sc/modules/ISC_Core.js:1214
                              ([object MouseEvent],(void 0))@http://localhost:8888/com.digitalage.ssb.MainSSB/sc/modules/ISC_Core.js:1201
                              ([object MouseEvent])@http://localhost:8888/com.digitalage.ssb.MainSSB/sc/modules/ISC_Core.js:1192
                              ((function (_1, _2) {var _3 = isc.EH;if (isc.Browser.isIE && !_3.$j6) {var _4 = _3.lastEvent;_4.eventType = _3.MOUSE_DOWN;_3.handleMouseDown(null, _3.lastEvent);}if (!_2) {_3.$ku = true;}var _5 = _3.$k5(_1, _2);_3.$ku = false;if (isc.Browser.isSafari) {_5 = true;}return _5;}),[object MouseEvent])@http://localhost:8888/com.digitalage.ssb.MainSSB/sc/modules/ISC_Core.js:1399
                              anonymous([object MouseEvent])@http://localhost:8888/com.digitalage.ssb.MainSSB/sc/modules/ISC_Core.js:35
                              IE coming tomorrow... (ops, it's already tomorrow)

                              [sleep mode on]

                              Comment

                              Working...
                              X