Announcement

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

    DataSource field descriptor documentation - where is it exactly?

    Version (not important) SmartClient Version: SNAPSHOT_v12.1d_2020-02-21/PowerEdition Deployment (built 2020-02-21)

    This conundrum was started by attempting to align the header of a ListGrid float field to Alignment.LEFT, when the field was defined from within a SQL Datasource XML file. It appears, confirmed by looking at the GWT Showcase, that the default behavior ( which is appropriate ) is to align column header text to the RIGHT for float and integer type fields.

    I attempted to confirm that by looking up the documentation, for the XML DataSource directive for 'type="float"'. I examined https://www.smartclient.com/smartgwt...urceField.html, and see that this applies to JAVA field definitions.

    I believe a few years ago I found/saw documentation on the raw XML descriptors of an XML Datasource, but I can't find it again. Can you point me to it?

    I can't google or find anything that states in words that float, or integer types cause the header text to align to the RIGHT. Does such documentation exist?

    I attempted to change the header title alignment to Alignment.LEFT in an override of the drawHandler for this grid, but that failed. I was finally able to change the alignment to LEFT by overriding the setFields() of ListGrid and forcing the setAlign(Alignment.LEFT) for that field. Does that seem correct to you? Shouldn't the drawHandler() override have worked?

    #2
    Those docs are the description of the .ds.xml DataSource descriptor. It says so right at the top of the page.

    DataSources cannot have component-specific properties, because they are used with multiple types of components (grids, forms, etc). You can set component-specific overrides in the fields of DataBoundComponents. This is all covered in the QuickStart Guide, Data Binding chapter. Default alignment behavior for ListGrid's is described where you would expect: ListGridField.align.

    The approach in the QuickStart Guide is much simpler than what you attempted, but not that if you want to change a field's property after draw, you use setFieldProperties().

    Comment


      #3
      Originally posted by Isomorphic View Post
      Those docs are the description of the .ds.xml DataSource descriptor. It says so right at the top of the page.
      OK. I was mistaken in believing I saw documentation some time ago which was not in the Javadoc form for this.

      Originally posted by Isomorphic View Post
      Default alignment behavior for ListGrid's is described where you would expect: ListGridField.align.
      I fail to see where the default alignment of Float and Integer types are described in ListGridField.setAlign(). I see this:

      Horizontal alignment for field's column header: "left", "right" or "center". Applied to the column header title and cells by default. A separate alignment for cells can be specified via cellAlign.
      If null, values are left-aligned. If this field is editable, the alignment of cells in the body will also be reflected in any editors for the field.


      I dont' see the documentation on ListGridField.align. I assume you mean ListGridField.setAlign() or .getAlign()?

      Originally posted by Isomorphic View Post
      The approach in the QuickStart Guide is much simpler than what you attempted, but not that if you want to change a field's property after draw, you use setFieldProperties().
      We have used the XML directive align="center" in the past. But:

      1. I was trying to figure out why the header title was being aligned to the Right for a float, and still can't find any description in a reference for this.

      2. We have used the directive in in the DataSource align="center" . But I don't see that directive (align) for instance described in
      https://www.smartclient.com/smartgwt...urceField.html,
      but using it in that DataBinding mode doesn't control the difference between setAlign() and setCellAlign(), Or are we imagining this works?

      <field name="Type" type="text" hidden="false" width="150" align="center" />

      3. We have not used setFieldProperties() in the past. Seems it is what I'm looking for. Is it used like this:

      this.setFieldProperties( 4, new ListGridField() { { setAlign( Alignment.RIGHT ) ; }}) ;

      ?

      Thanks

      Comment


        #4
        Hmm, the original documentation does discuss the default of right align, so we'll have to see how the SmartGWT JavaDoc, which is generated nightly from the SmartClient docs, is somehow stale.

        Setting align in DataSourceField XML is invalid, as it is not documented. If specified there, currently it would affect ListGrid and all other DBCs (DataBoundComponents), which would have different results in different DBCs. But this is not documented, so don't rely on it.

        That's a correct call to setFieldProperties(), but:

        1. as we covered just now, setFieldProperties is probably the wrong way to do what you are asking, unless you are trying to change alignment on the fly, for example, in response to some user action. Instead, you really really need to revisit the Data Binding chapter of the QuickStart, as you are missing out on a central feature of the product, that is, the ability to have shared information about an object that every DBC understands, and yet still be able to customize the appearance of any individual DBC, with minimal code and without repeating anything

        2. if you have an actual need to call setFieldProperties(), we'd recommend using the version that takes the field name rather than the field index, as users are allowed to rearrange, show and hide fields.

        Comment


          #5
          We have updated the docs for setAlign()/getAlign and you will see this update as of tomorrow's builds (Jan 23).

          Regards
          Isomorphic Software

          Comment


            #6
            Thanks. See it in the ListGridField.setAlign() documentation now.

            Comment

            Working...
            X