Uniface User Forum

 View Only
  • 1.  Get current occurrence from onmousover.

    PARTNER
    Posted 09-03-2020 16:30

    I've got a DSP where there's a list of items, Defined as a table. 

        

    In the operation, I've been pulling the number off the end of the ID and assuming it was the occurrence number in the entity. However, it appears this is not (always) the case. 

    Practically I've got a single field to the right of the table I want populated with data based on the mouseover occurrence. So, first question, how can I work out an occurrence number (or find the web ID from inside proc?)? 

    Second question, is there a better/faster trick for copying the data from a field in the occurrence (not displayed in the html layout) to a field in the page (fixed name, only one occurrence of this field)? 


    Regards, 

    Iain




  • 2.  RE: Get current occurrence from onmousover.

    Posted 09-03-2020 16:47

    Hi Iain,

    To answer your first question, you should try using this.getIndex() on the activate which is a function of the Ocurrence object.

    Keep in mind that you may need to use this.getIndex() + 1 if you're using setocc on the server side.

    Regards



  • 3.  RE: Get current occurrence from onmousover.

    PARTNER
    Posted 09-04-2020 08:51

    I had tried a couple of other things presuming this was a Uniface.occurrence, and they hadn't worked, but I tried with this one and it also returns that this.getIndex is not a function. 

    Regards, 

    Iain



  • 4.  RE: Get current occurrence from onmousover.
    Best Answer

    ROCKETEER
    Posted 09-04-2020 07:57

    Hi Iain,

    You could also consider setting a custom attribute on the Occurrence

    putitem/id $occproperties("myentity"), "html:data-occ", "%%($curocc("myentity") - 1)"

    or

    putitem/id $occproperties("myentity"), "html:data-hovertext", hoverovertext.myentity

    With one of the above, you should see the property set on the occurrence's HTML element and be able to get the value from javascript.

    Kind regards,

    Mike




  • 5.  RE: Get current occurrence from onmousover.

    PARTNER
    Posted 09-04-2020 09:36

    So, this turns out to be the best solution for my problem, and the second one allows me to populate the field in javascript without a round trip to the server, so that's even better. 

    Thanks. 

    Iain