Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

New API suggestion: ListGridField.setSortField(String sortField)

$
0
0
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

Viewing all articles
Browse latest Browse all 4756

Trending Articles