Hello!
I have a few questions.
This is the dataset retrieved from sql.
I want to show the value of a specific column in this table as a value of a different type.
For example, if the value of 'event ID' column is '1', I want to show it as 'inspection'.
thanks for your advice.
No, not simply. Dataset columns have a datatype--if the DB delivers numbers, any single updated value would also have to be number. You can get around this by replacing the entire column with strings, though.
Note, however, that if the table source data is a binding, then the next update will wipe out any changes you make in place. The typical solution to this varies by UI type:
-
In Perspective, you would add a transform to the binding to perform the substitution before delivery to the target property.
-
In Vision, you would move the binding to a custom property of the component and use an expression binding, perhaps with runScript(), to perform the necessary transform.
It would probably be easiest to simply do the transformation in the SQL query itself using the CASE function.
Example:
SELECT Model, Cabinet, Id, evtDate,
CASE eventID
WHEN 1 THEN 'inspection'
WHEN 2 THEN 'packing'
WHEN 3 THEN 'shipping'
ELSE 'unknown'
END AS eventDescription, evtStatus
FROM
#[...]
WHERE
#[...];
2 Likes
Or store the events names in another table and reference it in the query with a join, something like
SELECT ..., event_name
FROM your_table
INNER JOIN event_names
ON your_table.evtID = event_names.id
4 Likes