Macro Engine - Copy simple functions like '=PALO.ENAME(...)'

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • Macro Engine - Copy simple functions like '=PALO.ENAME(...)'

    Hi Community,

    i tried to copy a function via the webs macro engine, which works without any problem. Fun stuff though is that it looses its context calling functionality.

    Here's the macro:

    PHP Source Code

    1. function test_click()
    2. {
    3. $as = activesheet();
    4. $value = '=PALO.ENAME("localhost/Test";"Balance Sheet";"balance_check";1;"balance_check";"")';
    5. $as->range("B1:B5")->value = $value;
    6. }


    When I copy the formula from cell to cell using Crtl+C and Ctrl+V, and afterwards double click it the context window appears in which I am able to select one element. Anyways the cellinput written by the macro looses exactly that behavior. The result is still the one it should be which in this case is "balance check".

    I wasn't able to find a topic on this, if there is one please just post the corresponding link and i will close the topic.

    As always, any help is appreciated.

    Thanks in advance.

    Greets,
    Peter
  • I believe that events are somehow related to cell properties (see admin guide), maybe this information can be read from range::attributes. From my perspective needs some research. I'd appreciate if someone could help out - see the OOP topic for more info how this could be leveraged :)

    Madis
  • This macro will give you some interesting results (B2 contains PALO.ENAME from Paste Elements):

    PHP Source Code

    1. function test(){
    2. $s=activesheet();
    3. include 'NameFactory.php';
    4. $n=new NameFactory();
    5. $n->setRange('Sheet1','A10','=PALO.ENAME("localhost/Demo","Months","Year",1,"Year","")');
    6. $attr=$s->range('B2')->attributes;
    7. $n->setRange('Sheet1','B10',implode($attr));
    8. return true;
    9. }
    Display All


    However, I do not have success setting the attribute back to a cell.
  • Hey Maddis,

    tried it during vacation, but I was unable to write you my experiences on this any earlier.

    The result is indeed very interessting. I tried to locate the declaration files for the string your code generated, which is pretty easy using an editor that let's you jump through a project's files (just added the "Jedox Suite" folder), like in my case Sublime Text 3.

    {"dblclick":["hnd_dblCceOpen",{"working_mode":8,"serv_id":"localhost","db_name":"Demo","dim_name":"Months","edit_data":[["Year",null,"C"]]}],"palo_pe":{"type":"dim","name":"Months"}}

    But as I am a programming n00b still, I wasn't able to see why you could request that object properties, but not set it. (Tried it for some hours then gave up and started over a tutorial on JS again :D , I'll give it another try soon). Have you tried to locate the files, I can give you a list if needed, and to manipulate Jedox's code, to be able to pass this attribute object to individual cells? I am really missing such a feature.

    As always thanks again Madis, this really helped me to understand how Jedox handles the task.

    Greets,
    Peter
  • Hi Peter,

    Just referred to the manual and it says:

    range::attribute - will set an attribute with the passed "Key" to the passed "value".
    void range::attribute(Object value);

    From the returned text one could that this particular cells has two attributes: 'dblclick' and 'palo_pe' each one contaning an array. Since the documentation is a bit vague on the syntax this requires more experimenting. Like this it won't work:

    PHP Source Code

    1. $dblclk= array(
    2. 'hnd_dblCceOpen',
    3. array(
    4. 'working_mode'=>8,
    5. 'serv_id'=>'localhost',
    6. 'db_name'=>'Demo',
    7. 'dim_name'=>'Months',
    8. 'edit_data'=>array('Year',NULL,'C');
    9. )
    10. $s->range('A1')->attribute('dblclick':$dblclk); // looks like it only takes one argument but then again, why the other method is called range::attributes?


    I can not give it more try at the moment but I suspect you could try to pass entire array to the cell instead of parts of it or some Json which is just the representation in the JS land. The full array to be assigned:

    PHP Source Code

    1. $dblclk= array(
    2. 'hnd_dblCceOpen',
    3. array(
    4. 'working_mode'=>8,
    5. 'serv_id'=>'localhost',
    6. 'db_name'=>'Demo',
    7. 'dim_name'=>'Months',
    8. 'edit_data'=>array('Year',NULL,'C')
    9. );
    10. $palope= array(
    11. 'type'=>'dim',
    12. 'name'=>'months'
    13. );
    14. $final=array($dblclk,$palope);
    Display All


    Looks like a deep dive into PHP, JS and C++ :)
  • Hi Madis,

    well, as strange as it maybe sounds but it's lots of fun to get to know Jedox in depth.

    I forgot to mention that i tried to pass the whole string to the attributes method, but the result was - cannot set a value to attributes beause it's read only. I'm pretty sure you tried that too a while ago. However I'll keep trying, as I progress in learning all things it needs. The moment I reach the desired result I will update this post.

    Greets,
    Peter