Announcement

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

    New API suggestion: ListGridField.setSortField(String sortField)

    Hi Isomorphic,

    I have the following use-case:

    ds.xml with:
    Code:
    <field foreignKey="T_LEADTEMPERATURE.ID" name="LEADTEMPERATURE_ID" displayField="LEADTEMPERATURE_NAME" title="Leadtemperatur" type="integer" />
    <field name="LEADTEMPERATURE_NAME" includeFrom="T_LEADTEMPERATURE.NAME" hidden="true" />
    <field name="LEADTEMPERATURE_POSITION" includeFrom="T_LEADTEMPERATURE.POSITION" hidden="true" />
    I display the joined value for the ID. In my ListGridField for "LEADTEMPERATURE_ID" I have:
    Code:
    setSortNormalizer(new SortNormalizer() {
    	@Override
    	public Object normalize(ListGridRecord record, String fieldName) {
    		return record.getAttributeAsInt("LEADTEMPERATURE_POSITION");
    	}
    });
    This does work on the client (e.g. data displayed in order "Hot", "Medium", "Cold"). Nevertheless the SQL generated if I apply a sort to the ListGrid is ".... ORDER BY LEADTEMPERATURE_NAME" or even ".... ORDER BY LEADTEMPERATURE_ID" (when setting setSortByDisplayField(false)).

    This is clear as the SortNormalizer can't be converted to a ORDER-BY-Clause.

    I'd like to suggest an API ListGridField.setSortField(String sortField). It shouldn't be too different from what you are doing internally in case of setSortByDisplayField(true) right now, I'd guess.
    That way, simple SortNormalizers can be converted to a call to this API, allowing the serverside to do the sorting.
    Of course, you could also make this setting available as ds.xml field-level attribute.

    What do you think?

    Best regards,
    Blama

    #2
    Good suggestion. We'll probably add such a property as part of 5.0.

    Comment


      #3
      This feature has been added to 5.0 and will appear in nightly builds as of tomorrow.

      The actual property is dataSourceField.sortByField, as it affects both client and server sort order.

      Comment


        #4
        Sorry, a correction - this has been added to 5.1 only. It is not yet possible to download 5.1 builds, but it will be soon.

        Comment


          #5
          Hi Isomorphic,

          thanks for adding the API. I just found it in the docs: DataSourceField.setSortByField(String).

          I'm not using 5.1 (still on 4.1), but in order to be able to use it thorough in the future, the following two APIs / Enhancements are still missing IMO:


          Best regards,
          Blama

          Comment


            #6
            Hi Isomorphic,

            I just found the feature mentioned in you latest blog post. I'd like to use it from .ds.xml, but this is still not documented.

            Best regards
            Blama

            Comment


              #7
              Hi Blama,

              it is documented now, check upcoming nightly builds (from Dec 9).

              Thanks for the report,
              Isomorphic Software

              Comment


                #8
                Hi Isomorphic,

                I can see it now, thank you.

                Best regards
                Blama

                Comment

                Working...
                X