Hi,
I'm trying to add a column to a table in my low code app that counts down in real time.
I have a column of a datetime of a TAKE and a column with a duration and I want to count down until the TAKE + duration is <= Now.
My solution so far has been to create a custom GQI Operator called "Time left" and it looks like this:
public void HandleRow(GQIEditableRow row)
{
var timeOfLastTake = row.GetValue<DateTime>(_timeOfLastTakeColumn).ToLocalTime();
var timeOfLastStop = row.GetValue<DateTime>(_timeOfLastStopColumn).ToLocalTime();
var duration = row.GetValue<Double>(_durationColumn);
TimeSpan timeLeft = timeOfLastTake.AddSeconds(duration).Subtract(DateTime.Now);if (timeLeft <= TimeSpan.Zero || timeOfLastStop >= timeOfLastTake)
row.SetValue(_timeLeftColumn, TimeSpan.Zero);
else
row.SetValue(_timeLeftColumn, timeLeft);
}
The problem is that the low code app GUI doesn't refresh regularly enough. So I added a Trigger feed, set it to the lowest possible value of 5 seconds and connected it to the table and that kind of works but looks very janky and is not accurate enough.
Is there a better way to get a real time count down timer as a column in a low code app?
As this question has now been inactive for a long time, I will close it. If you still want more information about this, could you post a new question?
Hi Robin. In a custom operator this is not available, but in an ad hoc data source the iGqiUpdateable interface can be used to push updates to the client.
If your data is already coming from such ad hoc data source you could add the countdown column in there, and let it automatically update using a timer.
There is an example on GitHub that demonstrates how to use the iGqiUpdateable interface.
Hopefully this helps
The “updating” of the timer is then done on the server right?
That’s correct. In the ad hoc data source itself. A standard C#/.NET timer can be used as trigger.
Would it be reasonable to have a table with around 5-50 rows each a have a cell with an individual timer updating every 100ms or would this generate an unreasonable amount of traffic?
Although this approach would work, it’s additional traffic on the network for something that is preferably a client visualization. Unfortunately, I believe this is the only way though. Updating 10 times a second will create a lot of traffic, I would not advise this update rate. Is there any reason you want it to update this frequently?
In a broadcast environment you sometimes want to have a countdown for the operators.
I see that this question has been inactive for some time. Do you still need help with this? If not, could you select the answer (using the ✓ icon) to indicate that the question is resolved?