Announcement

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

    Defining and setting an expansion component using componentXML

    Is that possible? I am not able to figure out a working syntax.

    Thanks,
    fatzopilot

    #2
    You can use any of the built-in modes via Component XML.

    Defining an override for getExpansionComponent() would require subclassing ListGrid and using the "constructor" attribute (and this is only possible in 4.0+ - see the Reflection overview).

    Comment


      #3
      OK, I see. So there is no way to simply set (without subclassing the Grid) an componentXML definition (e.g. a form) as an expansion? Imo, that would make a lot of sense since it is basically UI design and it wouldn't interrupt your componentXML based UI design workflow by having to resort to plain old java, if all you'd like to do is to display a slightly modified version of the default details form or the like.

      Comment


        #4
        You're not really talking about a component definition, but a set of properties that could be used to create multiple components (since that's how getExpansionComponent() works).

        For any of the built-in expansion modes, there's a corresponding AutoChild that you can configure via Component XML normally.

        Comment


          #5
          OK, so I figured out this code

          Code:
          ...
          <DataSource>
              <loadID>Attachment</loadID>
          </DataSource>
          
          <ListGrid dataSource="ref:Attachment" autoFetchData="true" ID="AttachmentGrid" autoDraw="false" canExpandRecords="true"  expansionMode="editor" >
          	<expansionEditorProperties>
          		<DynamicForm autoDraw="false">
          		<fields>
          			<FormItem name="ButtonItem1" title="Save record" constructor="ButtonItem"></FormItem>
          		</fields>
          		</DynamicForm>
          	</expansionEditorProperties>
              <listEndEditAction>next</listEndEditAction>
              <showFilterEditor>true</showFilterEditor>
              <canEdit>true</canEdit>
              <canRemoveRecords>true</canRemoveRecords>
              <xsi:type>ListGrid</xsi:type>
          </ListGrid>
          
          ...
          which I belive is the way it should be done to show a simple button as an expansion (to start with).
          But then I get
          Code:
          ...
          16:25:00.619:MUP7:WARN:Log:ClassFactory.addGlobalID: ID:'isc_DynamicForm_0' for object '[DynamicForm ID:isc_DynamicForm_0]' collides with ID of existing object '[DynamicForm ID:isc_DynamicForm_0]'. The pre-existing widget will be destroyed.
          16:25:00.641:MUP7:WARN:DynamicForm:isc_DynamicForm_0:destroyed FormItem passed to setItems()/addItem(): FormItems cannot be re-used with different DynamicForms
          16:25:00.801:MUP7:WARN:Log:TypeError: _2 is null
          Stack from error.stack:
              unnamed(isc_c_DynamicForm_canEditFiel) @ gwt/com.aCompany.GWTModule/sc/modules/ISC_Forms.js:495
              unnamed(isc_FormItem_isReadOnl) @ gwt/com.aCompany.GWTModule/sc/modules/ISC_Forms.js:841
              unnamed(isc_CanvasItem_shouldDisableCanva) @ gwt/com.aCompany.GWTModule/sc/modules/ISC_Forms.js:1231
              unnamed(isc_CanvasItem__createCanva) @ gwt/com.aCompany.GWTModule/sc/modules/ISC_Forms.js:1199
              unnamed(isc_c_Class_invokeSupe) @ gwt/com.aCompany.GWTModule/sc/modules/ISC_Core.js:247
              unnamed(isc_c_Class_Supe) @ gwt/com.aCompany.GWTModule/sc/modules/ISC_Core.js:240
              unnamed(isc_ButtonItem__createCanva) @ gwt/com.aCompany.GWTModule/sc/modules/ISC_Forms.js:1348
              unnamed(isc_CanvasItem_ini) @ gwt/com.aCompany.GWTModule/sc/modules/ISC_Forms.js:1196
              unnamed(isc_Class_completeCreatio) @ gwt/com.aCompany.GWTModule/sc/modules/ISC_Core.js:284
              unnamed(isc_DynamicForm_createIte) @ gwt/com.aCompany.GWTModule/sc/modules/ISC_Forms.js:212
              unnamed(isc_DynamicForm__addItem) @ gwt/com.aCompany.GWTModule/sc/modules/ISC_Forms.js:198
              unnamed(isc_DynamicForm_setItem) @ gwt/com.aCompany.GWTModule/sc/modules/ISC_Forms.js:192
              unnamed(isc_DynamicForm_initWidge) @ gwt/com.aCompany.GWTModule/sc/modules/ISC_Forms.js:185
              unnamed(isc_Canvas_ini) @ gwt/com.aCompany.GWTModule/sc/modules/ISC_Core.js:1458
              unnamed(isc_Class_createAutoChil) @ gwt/com.aCompany.GWTModule/sc/modules/ISC_Core.js:321
              unnamed(isc_ListGrid__getStockEmbeddedComponen) @ gwt/com.aCompany.GWTModule/sc/modules/ISC_Grids.js:1247
              unnamed(isc_ListGrid_getExpansionComponen) @ gwt/com.aCompany.GWTModule/sc/modules/ISC_Grids.js:725
              unnamed(isc_ListGrid_expandRecor) @ gwt/com.aCompany.GWTModule/sc/modules/ISC_Grids.js:712
              unnamed(isc.A.expansionFieldDefaults.recordClic) @ gwt/com.aCompany.GWTModule/sc/modules/ISC_Grids.js:668
              unnamed(isc_ListGrid_rowClic) @ gwt/com.aCompany.GWTModule/sc/modules/ISC_Grids.js:1214
              unnamed(anonymou) @ gwt/com.aCompany.GWTModule/sc/modules/ISC_Grids.js:660
              unnamed(isc_GridRenderer__rowClic) @ gwt/com.aCompany.GWTModule/sc/modules/ISC_Grids.js:524
              unnamed(isc_c_Class_invokeSupe) @ gwt/com.aCompany.GWTModule/sc/modules/ISC_Core.js:247
              unnamed(isc_c_Class_Supe) @ gwt/com.aCompany.GWTModule/sc/modules/ISC_Core.js:240
              unnamed(isc_GridBody__rowClic) @ gwt/com.aCompany.GWTModule/sc/modules/ISC_Grids.js:585
              unnamed(isc_GridRenderer_clic) @ gwt/com.aCompany.GWTModule/sc/modules/ISC_Grids.js:522
              unnamed(isc_Canvas_handleClic) @ gwt/com.aCompany.GWTModule/sc/modules/ISC_Core.js:2166
              unnamed(isc_c_EventHandler_bubbleEven) @ gwt/com.aCompany.GWTModule/sc/modules/ISC_Core.js:1203
              unnamed(isc_c_EventHandler_handleClic) @ gwt/com.aCompany.GWTModule/sc/modules/ISC_Core.js:1079
              unnamed(isc_c_EventHandler__handleMouseU) @ gwt/com.aCompany.GWTModule/sc/modules/ISC_Core.js:1070
              unnamed(isc_c_EventHandler_handleMouseU) @ gwt/com.aCompany.GWTModule/sc/modules/ISC_Core.js:1062
              unnamed(isc_c_EventHandler_dispatc) @ gwt/com.aCompany.GWTModule/sc/modules/ISC_Core.js:1234
              unnamed(anonymou) @ gwt/com.aCompany.GWTModule/sc/modules/ISC_Core.js:63
              unnamed() @ 
          
          ...
          in the console. If I omit the "ButtonItem1" FormItem, the default editor expansion is shown. So what's wrong here?

          Since all I want to achieve with this for now is to create an expansion component containing a single upload field, I also tried this

          Code:
          ...
          <DataSource>
              <loadID>Attachment</loadID>
          </DataSource>
          
          <ListGrid dataSource="ref:Attachment" autoFetchData="true" ID="AttachmentGrid" autoDraw="false" canExpandRecords="true"  expansionMode="detailField" detailField="file">
              <listEndEditAction>next</listEndEditAction>
              <showFilterEditor>true</showFilterEditor>
              <canEdit>true</canEdit>
              <canRemoveRecords>true</canRemoveRecords>
              <xsi:type>ListGrid</xsi:type>
          </ListGrid>
          ...
          but the expansion component consisted of nothing as a thin frame.
          Note: The upload field in the expansion component should exist in addition to that in the parent grid (as the upload field in the parent list grid is not appropriate for uploading but nice for displaying purposes)

          Attachment.ds.xml:
          Code:
          ...
          <DataSource ID="Attachment"
              	xmlFromConfig="true"
          		beanClassName="com.aCompany.Attachment"
          		dataSourceVersion="1"
          		serverType="hibernate"
          		autoDeriveSchema="false"
          		dropExtraFields="true">
              <fields>
                  <field name="id" type="sequence" title="Id" primaryKey="true" detail="false">
                      <validators>
                          <Validator>
                              <type>isInteger</type>
                              <stopIfFalse>true</stopIfFalse>
                              <typeCastValidator>true</typeCastValidator>
                              <defaultErrorMessage></defaultErrorMessage>
                          </Validator>
                      </validators>
                  </field>
                  <field name="lastUpdated" type="date" title="Last Updated" detail="false" canView="true">
                      <validators>
                          <Validator>
                              <type>isDate</type>
                              <typeCastValidator>true</typeCastValidator>
                          </Validator>
                      </validators>
                  </field>
                  <field name="dateCreated" type="date" title="Date Created" detail="false" canView="true">
                      <validators>
                          <Validator>
                              <type>isDate</type>
                              <typeCastValidator>true</typeCastValidator>
                          </Validator>
                      </validators>
                  </field>
                  <field name="deleted" type="boolean" title="Deleted" detail="false" canView="true">
                      <validators>
                          <Validator>
                              <type>isBoolean</type>
                              <typeCastValidator>true</typeCastValidator>
                              <defaultErrorMessage></defaultErrorMessage>
                          </Validator>
                      </validators>
                  </field>
                  <field name="file" type="imageFile" title="File" detail="false" canFilter="false"></field>
               	<field name="file_filename" type="text" title="File name" detail="true"></field>
                  <field name="file_filesize" type="integer" title="File size" detail="true"></field>
                  <field name="file_date_created" type="date" title="File date created" detail="true"></field>
              </fields>
              <allowAdvancedCriteria>true</allowAdvancedCriteria>
              <xmlFromConfig>true</xmlFromConfig>
          </DataSource>
          ...
          So, what's the correct syntax to configure an AutoChild via ComponentXML?
          A related question: Is it possible shown the expansion already while the record is created for the first time (i.e. after triggering startEditingNew)?

          Thanks,
          fatzopilot

          Comment


            #6
            For configuring the AutoChild, set propertiesOnly="true" on that <DynamicForm>, otherwise, you are actually creating a DynamicForm (equivalent to isc.DynamicForm.create(..) in JS).

            On the second issue, you're going to get the DetailViewer's default rendering for a binary field, which would normally be icons to view and download the file, but it looks like the DetailViewer thinks there is no file in this record and so is showing nothing. This would happen if the "_filename" metadata field were null.

            Comment


              #7
              Originally posted by Isomorphic View Post
              For configuring the AutoChild, set propertiesOnly="true" on that <DynamicForm>, otherwise, you are actually creating a DynamicForm (equivalent to isc.DynamicForm.create(..) in JS).
              Thanks, that was the missing piece in the puzzle!

              Now I still wonder whether it possible to shown the expansion already while the record is created for the first time (i.e. after triggering startEditingNew)?

              Thanks,
              fatzopilot

              Comment


                #8
                Records that are newly created but not yet saved have special interactivity limitations. See the Handling Unsaved Records overview for details and alternative approaches.

                Comment


                  #9
                  OK, I think I have to rethink my approach.

                  Thanks for the pointer!

                  Comment

                  Working...
                  X