Tricky sorting and trigger activation

Author: zdenek.socha@fullsys.cz (sochaz)

Hello, we're facing a problem with trigger activation and sorting occurrences in a grid. I'll try to describe the situation. Short description: - user enter data in a field, then clicks on a column header to sort the entity, then leaves the field... some triggers are never activated (e.g. ValueChanged) Detailed description:

  • user enters data in a field
  • user decides to sort occurrences - so he clicks on a column header - this activates extended trigger, which calls a global procedure
  • sort is performed, setocc to the same occurrence before sorting and prompt is set back to the original field
  • some triggers are not fired, for example ValueChanged, $fieldendmod is not set

This is quite a problem... in common situation, when user enters data in a field (which is part of the primary key), these triggers are activated: Value Changed, Validate Field, Leave Field (with $fieldendmod set), Leave Modified Key, Next Field But if user sorts data... nothing is activated, but only Extended trigger of the grid widget... and upon leaving field, only these triggers are activated: Validate Field, Leave Field (with $fieldendmod *not* set), Leave Modified Key. So, Value Changed and Leave Field (with $fieldendmod set) is *never* activated. There seems to be no workaround for this bug. We're facing this problem only with grid widget, because with no grid, there are "sorting buttons" upon entity, so if user clicks this "sorting button", all triggers are activated *before* sorting, that is Value Changed, Validate Field, Leave Field etc.... but with grid widget, sorting is done on column headers, and Uniface skips all triggers. Have anyone tried to solve this problem? It seems to be quite complicated, since $fieldendmod can't be set. And according ulibrary, this function is valid only in Leave Field trigger, so we can't use it in extended trigger to check it prior sorting... even though, user leaves the field, Uniface skip some triggers and never fire them. Zdeněk

15 Comments

  1. Just fast thinking: I think you need "Value Changed" trigger to be fired... I suppose your grid is not taking the entire component space... What's about trapping user decision/needs into your grid Extended Trigger and executing real sorting outside your grid, after the "Value Changed"...just re-positioning user back into the grid after completing... You are in a FRM, right? Gianni


    Author: gianni (gianni.sandigliano@unifacesolutions.com)
  2. Yes, I'm in a form. And I need to activate all "leave triggers", that is Leave Field, Validate Field, Leave Modified Key and so on... that is what developer expects, but Uniface skips all those triggers. And there is no way to force structure editor to call them [explicitly]. In a meantime we have solved this problem. Instead of global proc for sorting, we place all information in a component variable, set prompt to a NPR,NED field (in a different entity) and call macro user key. In a user key trigger we check if the prompt is in the field, if yes, then we suppose all "leave triggers" (including validations) passed and then change prompt back and call the actual sorting. Otherwise (e.i. prompt is not in the expected field, which means leave field or validation did not passed), we clear the variable and do nothing. We use this workaround for several other things, not just sorting. This seems to work fine. It's a bit complicated and quite hard to globalize (the necessary proc code is scattered all around the component), but it solves the problem. Zdeněk Socha


    Author: sochaz (zdenek.socha@fullsys.cz)
  3. Hi Zdenek, Have you reported this bug to Support? Sounds like something that needs to be fixed. Theo


    Author: Theo Neeskens (tneeskens@itblockz.nl)
  4. sochaz said It's a bit complicated and quite hard to globalize (the necessary proc code is scattered all around the component), but it solves the problem. Zdeněk Socha

    Hi Zdeněk, have you tried to use the "Field gets Focus" Trigger instead of the Userkey Trigger?


    Author: ulrich-merkel (ulrichmerkel@web.de)
  5. ulrich-merkel said Hi Zdeněk, have you tried to use the "Field gets Focus" Trigger instead of the Userkey Trigger?

     I'm not sure, how would the "Field Gets Focus" trigger help here? On which field/widget? If Leave Field pass the prompt is set to a field with NED,NPR and this FGF is fired. And if Leave Field fails the prompt remains on original field. But we need to solve both situations. Zdeněk


    Author: sochaz (zdenek.socha@fullsys.cz)
  6. Theo Neeskens said Hi Zdenek, Have you reported this bug to Support? Sounds like something that needs to be fixed. Theo

    Hi Theo, What exactly do you consider a bug? The "leave triggers" (mainly Leave Field) is not fired upon several situations. For example if user types anything and then invoke a retrieve... even validations are not fired (mostly visible on fields of datatype "date"). I'm not sure if support can fix this as a bug. I'm afraid they consider this a behavior change, but I could try to report it. It would even help if we could fire these triggers explicitly (in a similar way as validation can be fired...) but we need to fire *all* triggers, including the "Leave Field" with $fieldendmod set  - but I'm afraid this is definitely request feature (for a wishlist?). From user point of view this trigger should be fired prior to do anything defined in ColumnHeader_LClicked trigger. But the same problem applies to many other actions, for example operations called via menu (pop-up menu or drop-down menu). This is very tricky in Uniface (everything is controlled by the structure editor, but we can't control the structure editor). Zdeněk


    Author: sochaz (zdenek.socha@fullsys.cz)
  7. Hi Zdeněk, FGF may be a better way to implement as the ^userkey you mentioned: The userkey trigger is a property of the component (sacttered ...) The FGF can be implemented with the modeled field, so all you have to do is to paint entity and field.


    Author: ulrich-merkel (ulrichmerkel@web.de)
  8. Hi Zdeněk, If you put in a $prompt which is not followed due to validation problems, I assuemd your user will get the necessary validation information which is sufficient in this case. And therefore is no need for further warnings etc. If FGF is reached anything is fine and it's time to do your sort.


    Author: ulrich-merkel (ulrichmerkel@web.de)
  9. Hi Uli, you are (partly) right. Please consider the situation, when validation fails... prompt is not set and no sorting is done. Now user corrects the error and click the field (with the "sorting" code in FGF trigger)... now the sorting is done, which is not what we need. In other words... we do not want to perform a sort every time FGF - I hope this is obvious. With User Key we do both, as I have mentioned earlier... if validation passed we clear the variable and sort, if validation failed we clear the variable and do nothing. There is no way for user to activate the user key (with that "sorting code"). Zdeněk


    Author: sochaz (zdenek.socha@fullsys.cz)
  10. I haven't had time to investigate - particularly the key validation - but surely simple field validation could be completed with trigger ColumnHeader_LClicked params string fieldName: in numeric shiftKey: in endparams if ($fieldvalidation(fieldName)) validatefield fieldName endif sort $entname fieldname That would fire the Validate Field trigger.  If this is an editbox, I would try to avoid use of Value Changed: That trigger is, I believe, more suited to use with widgets such as dropdownlists and radio groups.  If the field is validating, then the value has changed in some way in any event, has it not? Validatekey - might that work too? As I say, I haven't had the time to test.  I will try and do so later.  Just my first thought.   Dave


    Author: None (None)
  11. Sorry, ignore my last - missed my mistake.   Dave


    Author: None (None)
  12. Apologies for my earlier error.  I think this would fire the Validate Field trigger but it would depend what you were doing in that trigger whether it would get back to complete the sort.  With a simple calculation  and field assignment in the Validate Field it works fine.   trigger ColumnHeader_LClicked params string fieldName: in numeric shiftKey: in endparams validateocc sort $entname fieldname $prompt=fieldName Validateocc would, of course, fire any other outstanding occurrence level validation which might be an unwelcome side effect. Dave


    Author: None (None)
  13. sochaz said In other words... we do not want to perform a sort every time FGF - I hope this is obvious. With User Key we do both, as I have mentioned earlier... if validation passed we clear the variable and sort, if validation failed we clear the variable and do nothing.

    Hi again, i checked my notes and found that I just forgot that in the ecosystem I used there was a standard routine in every validation error trigger and one of the responsibilities of that routine was to empty the "process_next" information. which is, in your case, the sort which will be emptied in the UserKey trigger. Good Night from Frankfurt/Germany, Uli


    Author: ulrich-merkel (ulrichmerkel@web.de)
  14. Hi Zdeněk It seems, that the group-header behaves like a control-comand-button. And with control-buttons, there is no verfication at all. But there is maybe a workaround: Just use the DEFORMAT-trigger. This one will be fired every time a user leaves the field, no matter in which way (except Dr.Watson&Co regards Ingo


    Author: istiller (i2stiller@gmx.de)
  15. FYI   The header buttons in the grid are a kind of labels with extended triggers attached to them. You do not draw them in the graphical form painter and so when you click them the active path in UNIFACE does not change. If the active path is not changing the valuechange trigger will not be fired not will there any focus trigger fired. Although this is the UNIFACE behavior it is cumbersome to work with in this example. I think that you should contact UNIFACE support to see whether they can report a bug for this. Succes Jasper


    Author: Jasper (jasper.de.keijzer@compuware.com)