Table sort by mouseclick on a header is a powerful feature in table forms (second mouseclick on a second header wile holding shift-key enables a second sort).
However in some tables it can confuse users, e.g. in a typical order lines table, when the user accidentally hits a table header and suddenly all order lines have a new order.
A simple way to prevent this is to code a generic scopes.utils.doNothing() function with empty body.
Then select all headers with the lasso and hook their onAction event up to doNothing(), that's it.
showClick and showFocus need to be disabled on those headers to still look nice, though.
(Setting enable to false will not help, as it renders the header text to a non-wanted font.)
"Do nothing and everything is done" was already recommended by Lao Tze:
http://tao-in-you.com/do-nothing-in-order-to-do-more/
BTW, the table sort by header mouseclick does not work on non-stored calculated fields. In those cases a function can be used on the onAction() of that table field header, which will sort explicitly with foundset.sort("my_sort_field"). But my_sort_field can not be the calculated field, it must be something else. If everything fails a directSQL with sorting to stuff the foundset will possibly help, but that is certainly a bit much in most cases.
JavaScript does not distinguish between integers and numbers - but Servoy does...
JavaScript has just one number type: number - that's it.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures
Recently I needed a form variable to hold the total of some table lines.
However the total was always without decimals, until I figured out why.
In such cases, it is important to define the form var properly with " = 0.0", Servoy will then add another variableType, as can be seen here:
- Code: Select all
/**
* @type {Number}
* @properties={typeid:35,uuid:"DD54DF8C-D5D3-4D98-9A8E-4852DE6EE91F",variableType:4}
*/
var _iTotalOrderValue = 0; // will not work properly, decimals will get cut!
/**
* @type {Number}
* @properties={typeid:35,uuid:"6A81AD82-FDB3-4495-A679-7ECF296FB33F",variableType:8}
*/
var _nTotalOrderValue = 0.0;
To hold this in mind, I will now define pure integers with prefix _i in front, and real numbers with _n in front.