Today I learned

Share business templates, ideas, experiences, etc with fellow Servoy developers here

Table Sort / Number vs. Integer

Postby Bernd.N » Tue Oct 11, 2016 2:40 pm

Preventing table sort
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: :wink:
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.
Bernd Korthaus
LinkedIn
Servoy 7.4.9 SC postgreSQL 9.4.11 Windows 10 Pro
User avatar
Bernd.N
 
Posts: 544
Joined: Mon Oct 21, 2013 5:57 pm
Location: Langenhorn, North Friesland, Germany

JIRA Software and JIRA Service Desk

Postby Bernd.N » Thu Oct 20, 2016 2:11 am

I am really amazed how good both JIRA packages work together under one hood, and for startups like us they cost nearly nothing.
So it is no problem for example to add issues from both packages into one sprint.
The advantage of JIRA Service Desk is that you can create as many "reporter users" from your customer users as you want, without extra charge.
And as it is so widespread used, one can quickly google answers to any upcoming questions regarding configuration.
Additionally, the JIRA support is really fast and responsive.

We also started Confluence to create a structured knowledge base for everything in our company, like coding guidelines, marketing strategy etc., it also works like a charm.

Those tools are clearly a recommendation for everyone who works with a team, regardless of size. We pay now just 30$/month for all three.
Bernd Korthaus
LinkedIn
Servoy 7.4.9 SC postgreSQL 9.4.11 Windows 10 Pro
User avatar
Bernd.N
 
Posts: 544
Joined: Mon Oct 21, 2013 5:57 pm
Location: Langenhorn, North Friesland, Germany

The pitfall of the X/Close-Button in modal windows

Postby Bernd.N » Tue Mar 14, 2017 9:58 am

Modal window dialogs are handy, e.g. to put in "small" records which belong to larger ones.
When making them moveable, to my knowledge you can not prevent that on the right upper side the red close button in form of a X appears (at least on Windows systems).

Today I learned that you always have to take into account that users will not press either your Save or Cancel buttons, but sometimes move their mouse to the much smaller X button that is not that easy to reach.
In my case that meant that code that I expected to run did not run, and some form variables where not cleared, which should have been the task of the cancel button.

A non wanted side effect in new records was the result. That could be solved by always calling the clearFormVariables()-function before creating a new record.
In case someone knows about getting rid of that X/Close-button, or if there is a method that fires when the user clicks it, I would be happy to hear about that.
Bernd Korthaus
LinkedIn
Servoy 7.4.9 SC postgreSQL 9.4.11 Windows 10 Pro
User avatar
Bernd.N
 
Posts: 544
Joined: Mon Oct 21, 2013 5:57 pm
Location: Langenhorn, North Friesland, Germany

Re: Today I learned

Postby jbrancoIF » Tue Mar 14, 2017 10:25 am

You have two options for the dialog close. (To my knowledge it's not possible to get rid of the button so you'll have to handle it)
- you use the dialog form onHide that gets called when the x button is clicked
- on the function that creates the dialog, you set a flag on the dialog form and you change that flag if ok/cancel are clicked. if the flag was not changed you know it was the X button
Code: Select all
var dialog = forms.dialog;
dialog.flag = -1;

var w = application.createWindow('Dialog', JSWindow.MODAL_DIALOG);
w.show(dialog);

if (dialog.flag == -1)
   // X button
else if (dialog.flag == 0)
   // cancel button
else if if (dialog.flag == 1)
   // ok button
João
InfoForm SA

Servoy 2021.03
jbrancoIF
 
Posts: 68
Joined: Tue Jan 10, 2012 11:29 am

Re: Today I learned

Postby patrick » Tue Mar 14, 2017 10:30 am

Another approach would be to simply "ignore" the X by letting the onHide method return false if no button was clicked. When a button is clicked, you could set a variable buttonClicked = true. In the onHide method you could then do this

Code: Select all
if (buttonClicked === true) {
   return true;
}
return false;


Many people also ask the user whether he wants to cancel or save

Code: Select all
if (buttonClicked !== true) {
   //ask to save or cancel
}
return true;
Patrick Ruhsert
Servoy DACH
patrick
 
Posts: 3709
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

Re: Today I learned

Postby Bernd.N » Tue Mar 14, 2017 11:16 am

Thank you both for the tips!
Bernd Korthaus
LinkedIn
Servoy 7.4.9 SC postgreSQL 9.4.11 Windows 10 Pro
User avatar
Bernd.N
 
Posts: 544
Joined: Mon Oct 21, 2013 5:57 pm
Location: Langenhorn, North Friesland, Germany

Previous

Return to Sharing Central

Who is online

Users browsing this forum: No registered users and 1 guest

cron