Announcement

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

    Use Nested Form in Grid for Adding Records?

    Should I be able to use a nested form inside of a grid for entering records?

    We're working with a setup where the getExpansionComponent override is being used to attach a form to a grid, where some fields are entered within the grid while other fields must be entered on an expanded form.

    Setup works OK on an existing record but if I try expanding the grid record before saving it, I get the following exception in the GWT Development mode console:

    com.google.gwt.core.client.JavaScriptException: (String): Invoking an instance method on a null instance 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.ModuleSpace.createJavaScriptException(ModuleSpace.java:65) at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:60) 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.invokeNativeBoolean(ModuleSpace.java:179) at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeBoolean(JavaScriptHost.java:35) at com.smartgwt.client.widgets.grid.ListGrid.canExpandRecord(ListGrid.java) at sun.reflect.GeneratedMethodAccessor45.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.GeneratedMethodAccessor26.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:619)

    Just checking to see if this should even work before digging further and putting together a test case. This was in SmartGWT 2.1 and Firefox 3.6.

    Ed

    #2
    After thinking a bit, I figured out that I can't expand the nested form for a record being added because no ListGridRecord exists yet. So I thought I would save my add using saveAllEdits and then use the Function/Execute to call ExpandRecord since I should have a ListGridRecord then. This worked fine when I didn't retrieve data into the grid but as soon as I did a FetchData on the grid before adding the record, I don't have a ListGridRecord anymore and get the following in the developer console:

    00:18:43.864 [ERROR] 08:23:43.345:XRP5:WARN:ListGrid:isc_OID_143:Record:{allocationKey: 844}, lost from local cache in paged result set. Pending edits for this record will be maintained.
    com.smartgwt.client.core.JsObject$SGWT_WARN: 08:23:43.345:XRP5:WARN:ListGrid:isc_OID_143:Record:{allocationKey: 844}, lost from local cache in paged result set. Pending edits for this record will be maintained. 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.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:619)

    So I can currently work around this by doing an invalidateCache/draw on the grid and then manually expanding the row.

    Still looking for a way I can automatically trigger an expansion of a nested form for a row after adding the row.

    Ed

    Comment


      #3
      Take a look at the Editing overview in the docs package - there won't be a ListGridRecord for an unsaved row but you can retrieve the values currently entered for the row via getEditValues().

      By the way, you may as well update to 2.2 - better interlinking in the docs and some fixes to this subsystem.

      Comment


        #4
        Thanks for the reply, sorry I didn't read up on the docs before posting and that was helpful.

        Still looking for an answer to my 2nd message that I'm not seeing in the docs, after doing a saveAllEdits and using a Function callback, should the ListGridRecord for a new row exist in the callback so that I can call an ExpandRecord on it at that time. I'm seeing inconsistent results on that depending on whether I do a FetchData on the grid before adding a record.

        I can update to 2.2 and/or demonstrate the problem with a test case and I think first I need to know how it should work.

        Ed

        Comment


          #5
          saveAlllEdits will save edits performed via the inline editor in the grid. It's not clear what you're expecting it to do in this case - if there were a new record being created, and you wantto create it before you beging editing it with the nested form, the best approach is probably to call DataSource.addData() directly, then when the callback fires, look up the new record
          in the grid by matching primary key (it will appear there automatically, via cache synch) and programmatically expand it to beging editing.

          Comment


            #6
            I am looking at your example for list with nested form. I was wondering how you would add a new row?

            Comment

            Working...
            X