Jump to content

steve589

uniGUI Subscriber
  • Posts

    39
  • Joined

  • Last visited

Posts posted by steve589

  1. You wrote: "Yes, it will be available on the server side"

    Did you mean "Yes, it will be available on the client side"?

     

    This would be fine  :),

    but there is no need to hurry, I found a very simple solution (rather a hack):

     

    I put the anchor hidden in the text property:

        Nd := NavTree.Items.Add(nil, '<span "' + sAnchor + '">' + sText + '</span>');

     

    and then I can get it like so:
    NavTree.ClientEvents.ExtEvents.Values['itemclick'] := 'function itemclick(sender, record, item, index, e, eOpts) {' +
          'var iPos = record.data.text.indexOf(">") - 1,' +
          '    anchor = record.data.text.substring(7, iPos),' +
          '    elTo = ' + UniURLFrame1.JSName + '.iframe.contentWindow.document.getElementById(anchor);' +
          'if (elTo) {' +
          '  ' + UniURLFrame1.JSName + '.iframe.contentWindow.document.scrollingElement.scrollTop = elTo.offsetTop - 5;' +
          '}' +
       '}';
    
    
  2. well, something is not working with this solution, I get the alert:

    "Cannot read property 'data' of null"

     

    when I set a breakpoint at

        O93.store.getNodeById(1).data._ID = 1;

    and check in the console

        O93.store.getNodeById(1)

    the result is null

     

    after closing the alert the page is not visible, but when I then check again the console it gives me:

       constructor {$observableInitialized: true, hasListeners: j, eventedBeforeEventNames: {…}, events: {…}, initConfig: ƒ, …}

     

    obviously the object does not exist at load-time yet

     

    any Ideas?

  3. Hi,

    is it possible to access the data of a UniTreeNode in javascript on the page?

    I could not figure out how to do this.

    Sencha treenode also has a data-property which can be accessed, but this is obviously not the same.

     

    I added a value to a UniTreeNode like so:

     

    type
      TNodeInfo = class(TObject)
        ID: Integer;
        scrollTo: String;
      end;
     
    procedure addNode(NavTree: TUniTreeView; ID: Integer; sText, sAnchor: String);
    var Nd: TUniTreeNode;
          Ni: TNodeInfo;
    begin
           Ni := TNodeInfo.Create;
           Ni.ID := ID;
           Ni.scrollTo := sAnchor;
     
           Nd := NavTree.Items.Add(nil, sText);
           Nd.Data := Ni;
    end;
     
    In ExtEvents "itemclick" I can access record.data, but my added ID and scrollTo - properties are not available.
     
    Thanks for help.
    Steve
  4. Yes, this works from outside the frame!

     

    From inside the frame it would be (added to the HTML at UniForm.Create):

    '    parent.' + UniURLFrame1.JSName + '.iframe.contentWindow.document.scrollingElement.scrollTop = 0;'
    or
    '    parent.' + UniURLFrame1.JSName + '.iframe.contentWindow.document.scrollingElement.scrollTop = elTo.offsetParent';'
    where elTo is the element to scroll to.
     
    with javascript from outside the frame (f.i. from Ext ClientEvent, added to the ClientEvent at UniForm.Create):
    '   var elTo = ' + UniURLFrame1.JSName + '.iframe.contentWindow.document.getElementById("some_ID");' +
    '   if (elTo) {' +
    '      UniURLFrame1.JSName + '.iframe.contentWindow.document.scrollingElement.scrollTop = elTo.offsetTop;' +
    '   }'
     
    Excellent support!

    Thanks a lot!

    Steve

  5. Hi,

    how can I scroll programatically in UniURLFrame?

    I used to do this in javascript like so:

        elTo.offsetParent.scrollTop = elTo.offsetTop;

    But this does not work in UniURLFrame...

    Any ideas?

    Thanks for help

    steve

  6. in MainForm there is only one UniURLFrame, then:

     

    procedure TMainForm.UniFormCreate(Sender: TObject);
    begin
        UniURLFrame1.HTML.Text := 
            '<script type="text/javascript">' +
            '   document.addEventListener("click", function(e) { ' +
            '       parent.ajaxRequest(' + UniURLFrame1.JSName + ', "ClickEvent", [ "param0=a", "param1=b" ]);' +
            '   })' +
            '</script>' +
            '<br>' +
            'click here' +
            '<br>';
    end;
     
    // this is never called:
    procedure TMainForm.UniURLFrame1AjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings);
    begin
        ShowMessage(Params.Values['param0'] + ' - ' + Params.Values['param1']);
    end;
  7. Hi,

    I cannot figure out how to fire the OnAjaxEvent from JS-code within the loaded page.

    ajaxRequest can be called with "parent.ajaxRequest", but I cannot determine the first parameter "sender"

     

    I tried:

      - parent.ajaxRequest(this, "ClickEvent", [ "param0=a", "param1=b" ]);

      - parent.ajaxRequest(O3C, "ClickEvent", [ "param0=a", "param1=b" ]);  // where "O3C" is the JS-name of the UniURLFrame (added via code on startup)

      - tried to get a reference to the UniURLFrame-control with:

          - var x = parent.getElementById("O3C");       // x is null

          - var x = parent.getElementById("O3C_id");  // x is null

    nothing works.

     

    Can anybody help please?

    best regards

    steve

     

  8. Well at least I would have to know when a link is clicked (navigate to another page).

    But also mouseover and mouseout would be helpful.

     

    Another possiblity would be to have an event that fires when a javascript function is executed from within the page.

    This would be more generic then...

  9. Hi all,

     

    I'm using a UniURLFrame in a TabSheet and want to add another TabSheet to the PageControl when clicking a link in the HTML-document.

    How can this be done?

     

    The link can call a javascript function (onclick="parent.addTabSheet('new Tabsheet')"), but I found no way to implement this function somewhere.

    Is this possibel at all?

     

    Thanks a lot for help.

    Stephen

×
×
  • Create New...