SmartClient Version: v13.0p_2022-08-13/Enterprise Deployment (built 2022-08-13)
We're seeing an unexpected behaviour for hilites on DateTime ListGridFields that don't have a backing DataSourceField. I've written this minimal example:
So we have a datasource with two fields and we add two more fields directly in the ListGrid and we set these hilites definitions:
The hilites based on absolute values work (h1,h2,h3,h4) as expected.
But the hilites based on relative date values (h2_2, h4_2) don't. On the datasource-backed datetime field it works if I open the "Edit Highlights" windows and save without any modifications:
But not for the datetime field that does not correspond to a dsfield.
Is that an expected behaviour, or is there something we can fix for that behaviour?
Regards
We're seeing an unexpected behaviour for hilites on DateTime ListGridFields that don't have a backing DataSourceField. I've written this minimal example:
Code:
package ch.namlin.smartboot.client; import java.util.Date; import com.google.gwt.core.client.EntryPoint; import com.smartgwt.client.data.AdvancedCriteria; import com.smartgwt.client.data.DataSource; import com.smartgwt.client.data.DataSourceField; import com.smartgwt.client.data.Hilite; import com.smartgwt.client.data.RelativeDate; import com.smartgwt.client.data.fields.DataSourceIntegerField; import com.smartgwt.client.types.DSDataFormat; import com.smartgwt.client.types.FieldType; import com.smartgwt.client.types.ListGridFieldType; import com.smartgwt.client.types.OperatorId; import com.smartgwt.client.widgets.IButton; import com.smartgwt.client.widgets.grid.ListGrid; import com.smartgwt.client.widgets.grid.ListGridField; import com.smartgwt.client.widgets.grid.ListGridRecord; import com.smartgwt.client.widgets.layout.VLayout; public class DateEntryPoint implements EntryPoint { @Override public void onModuleLoad() { VLayout layout = new VLayout(); layout.setWidth100(); layout.setHeight100(); layout.setPadding(20); ListGrid grid = new ListGrid(); grid.setDataSource(CountryDS.getInstance()); grid.setAutoFetchData(true); grid.setCanEdit(true); grid.setCanEditHilites(true); ListGridField additionalTextField = new ListGridField(); additionalTextField.setHidden(false); additionalTextField.setCanHilite(true); additionalTextField.setType(ListGridFieldType.TEXT); additionalTextField.setName("MetaTreeColumn_547"); additionalTextField.setTitle("Text"); ListGridField additionalDateField = new ListGridField(); additionalDateField.setHidden(false); additionalDateField.setCanHilite(true); additionalDateField.setType(ListGridFieldType.DATETIME); additionalDateField.setName("MetaTreeColumn_548"); additionalDateField.setTitle("Created on"); ListGridField countryCodeField = new ListGridField("countryCode", "Country code"); ListGridField dateField = new ListGridField("date", "Date"); grid.setFields(countryCodeField, dateField, additionalTextField, additionalDateField); Hilite h1 = new Hilite().setTitle("H1").setFieldName("countryCode").setBackgroundColor("#99CC00"); h1.setCriteria(new AdvancedCriteria("countryCode", OperatorId.ICONTAINS, "1")); Hilite h2 = new Hilite().setTitle("H2").setFieldName("date").setBackgroundColor("#99CC00"); h2.setCriteria(new AdvancedCriteria("date", OperatorId.GREATER_THAN, new Date(100L))); Hilite h2_2 = new Hilite().setTitle("H2_2").setFieldName("date").setTextColor("#FF9900"); h2_2.setCriteria(new AdvancedCriteria("date", OperatorId.GREATER_THAN, RelativeDate.YESTERDAY.getValue())); Hilite h3 = new Hilite().setTitle("H3").setFieldName("MetaTreeColumn_547").setBackgroundColor("#99CC00"); h3.setCriteria(new AdvancedCriteria("MetaTreeColumn_547", OperatorId.ICONTAINS, "A")); Hilite h4 = new Hilite().setTitle("H4").setFieldName("MetaTreeColumn_548").setBackgroundColor("#99CC00"); h4.setCriteria(new AdvancedCriteria("MetaTreeColumn_548", OperatorId.GREATER_THAN, new Date(100L))); Hilite h4_2 = new Hilite().setTitle("H4_2").setFieldName("MetaTreeColumn_548").setTextColor("#FF9900"); h4_2.setCriteria(new AdvancedCriteria("MetaTreeColumn_548", OperatorId.GREATER_THAN, RelativeDate.YESTERDAY.getValue())); grid.setHilites(new Hilite[]{h1, h2, h2_2, h3, h4, h4_2}); grid.addDataArrivedHandler(dataArrivedEvent -> { for (ListGridRecord record : grid.getRecords()) { record.setAttribute("MetaTreeColumn_547", "AABBCCD"); record.setAttribute("MetaTreeColumn_548", new Date()); } }); layout.addMember(grid); IButton addCountry = new IButton("Add new country"); addCountry.addClickHandler(event -> { ListGridRecord rec = new ListGridRecord(); int number = getNextNumber(); rec.setAttribute("pk", number); rec.setAttribute("countryCode", "A" + number); rec.setAttribute("countryName", "Country " + number); rec.setAttribute("capital", "Capital " + number); rec.setAttribute("date", new Date()); grid.addData(rec); }); addCountry.setLeft(0); addCountry.setTop(240); addCountry.setWidth(140); layout.addMember(addCountry); layout.draw(); } private int counter = 1; private int getNextNumber() { return counter++; } private static class CountryDS extends DataSource { // The DataSource would normally be defined external to any classes that use it. private static CountryDS instance = null; public static CountryDS getInstance() { if (instance == null) { instance = new CountryDS("Country"); } return instance; } public CountryDS(String id) { setID(id); setDataFormat(DSDataFormat.XML); DataSourceIntegerField pkField = new DataSourceIntegerField("pk"); pkField.setHidden(true); pkField.setPrimaryKey(true); DataSourceField countryCodeField = new DataSourceField("countryCode", FieldType.TEXT, "Code"); DataSourceField dateField = new DataSourceField("date", FieldType.DATETIME, "Date"); setFields(pkField, countryCodeField, dateField); setClientOnly(true); } } }
The hilites based on absolute values work (h1,h2,h3,h4) as expected.
But the hilites based on relative date values (h2_2, h4_2) don't. On the datasource-backed datetime field it works if I open the "Edit Highlights" windows and save without any modifications:
But not for the datetime field that does not correspond to a dsfield.
Is that an expected behaviour, or is there something we can fix for that behaviour?
Regards
Comment