FoxInCloud
grid - order by date
Gravatar is a globally recognized avatar based on your email address. grid - order by date
  Vincent H.
  All
  Feb 14, 2020 @ 12:29am

Hi Thierry,

I have an (old) problem with the order of display in a grid.
On a column whose source field is a date, nothing happens when clicking on the title. All the other columns respond well.
Is there a special requirement for a column to be ordered ?

Gravatar is a globally recognized avatar based on your email address. re: grid - order by date
  Vincent H.
  Vincent H.
  Feb 14, 2020 @ 12:45am

Found !
When the date of the current line (in grid) is empty, the classification does not take place.

Gravatar is a globally recognized avatar based on your email address. re: grid - order by date
  Vincent H.
  Vincent H.
  Feb 17, 2020 @ 06:22am

Can we envisage a solution to this problem ?
Thanks in advance

Gravatar is a globally recognized avatar based on your email address. re: grid - order by date
  FoxInCloud Support - Thierry N.
  Vincent H.
  Feb 17, 2020 @ 09:39am

The sorting mechanism lies inside ActiveWidgets so I need some time to figure out how we can override or complement it.

Meanwhile, if you use a cursor, you can try to replace empty dates by null

Select evl(date, .null.) as date …
Gravatar is a globally recognized avatar based on your email address. re: grid - order by date
  Vincent H.
  FoxInCloud Support - Thierry N.
  Feb 17, 2020 @ 11:02am

I tried:

CAST (EVL (Dateouvert, .NULL.) AS D) AS Dateouvert

without success ...

Gravatar is a globally recognized avatar based on your email address. re: grid - order by date
  FoxInCloud Support - Thierry N.
  Vincent H.
  Feb 18, 2020 @ 12:22am

Hi Vincent,

After further inquiry, ActiveWidgets considers an empty date as an erroneous data, probable reason why the sort does not happen (empty dates exist in VFP only).

We could maybe replace, in the XML data of the grid contents, all empty dates by a 'fake date' (e.g. 1000-01-01) and modify the client side display logic (see AW.Formats.DateVFP in FoxInCloud.js) to display an empty date instead.

Could you find a way to avoid an empty date?

Another alternative is to implement the sort on server side, e.g. by implementing header.click().

Gravatar is a globally recognized avatar based on your email address. re: grid - order by date
  FoxInCloud Support - Thierry N.
  Vincent H.
  Feb 18, 2020 @ 02:56am

I may have found a solution… please try this fix in development mode:

In FoxInCloud.js (use an UTF-8 editor such as notePad++)

  /* Date data format supporting empty date like VFP */
  AW.Formats.DateVFP = AW.Formats.Date.subclass();
  AW.Formats.DateVFP.create = function(){
    AW.Formats.Date.create.call(this);
    this.prototype.setErrorText(FoxInCloud.gridDateEmpty);
    this.prototype.setErrorValue(0); // ADD THIS LINE
  };

  /* Datetime data format supporting empty date-time like VFP */
  AW.Formats.DateTimeVFP = AW.Formats.Date.subclass();
  AW.Formats.DateTimeVFP.create = function(){
    AW.Formats.Date.create.call(this);
    this.prototype.setErrorText(FoxInCloud.gridDateTimeEmpty);
    this.prototype.setErrorValue(0); // ADD THIS LINE
  };

Gravatar is a globally recognized avatar based on your email address. re: grid - order by date
  Vincent H.
  FoxInCloud Support - Thierry N.
  Feb 18, 2020 @ 03:42am

Bravo Thierry !
It works perfectly

Gravatar is a globally recognized avatar based on your email address. re: grid - order by date
  FoxInCloud Support - Thierry N.
  Vincent H.
  Feb 18, 2020 @ 04:00am

Could you also try this?

this.prototype.setErrorValue(new Date(1000, 0, 1)); // before any VFP date
Gravatar is a globally recognized avatar based on your email address. re: grid - order by date
  Vincent H.
  FoxInCloud Support - Thierry N.
  Feb 18, 2020 @ 04:29am

Also good !

/* this.prototype.setErrorValue(0); // ADD THIS LINE - 18/02/2020 */  
this.prototype.setErrorValue(new Date(1000, 0, 1)); // before any VFP date
Gravatar is a globally recognized avatar based on your email address. re: grid - order by date
  Vincent H.
  Vincent H.
  Feb 18, 2020 @ 10:47am

Usable in production or is it better to wait a little bit ?

Gravatar is a globally recognized avatar based on your email address. re: grid - order by date
  FoxInCloud Support - Thierry N.
  Vincent H.
  Feb 18, 2020 @ 11:59am

You need to wait for the next release as FoxInCloud.js for production is different from development (minified).

© 1996-2020