Results 1 to 9 of 9
  1. #1
    Member
    Join Date
    Jan 2011
    Location
    Redhill
    Posts
    9

    items entering visible logical page

    Hi,

    I have a DynaMetapushTable in COMMAND mode, there are 36 items (rows) in the table, but only 12 are visible (that makes 3 pages of 12 items).

    One of the columns needs special treatment when it is displayed. It can contain 0 or 1 text value, or a set of divs. In the latter case, I need to rotate the content of the divs, I am doing that by setting a style in onChangingValues and stopping and starting an animation using the jQuery cycle plugin.

    The problem is, that I get a notification via onChangingValues/VisualUpdateInfo even is the value added/updated is not on the logical page that is currently being displayed. So starting and stopping and animation that is not actually in the DOM gives a js error.

    Is there an event raised by the Lightstreamer js client library that notifies the client that a record has entered the currently displayed logical page (coming from an undisplayed page, for example because a row has been deleted)?

    Is there a way of knowing, that a record added or updated and raising an onChangingValues is not part of the currently displayed logical page?

    Thanks for your help!
    Emese

  2. #2
    Power Member
    Join Date
    Jul 2006
    Location
    Cesano Maderno, Italy
    Posts
    784
    Hi

    Is there a way of knowing, that a record added or updated and raising an onChangingValues is not part of the currently displayed logical page?.
    we do not pass such information through the onChangingValues event;
    you may solve this checking by checking if the DOM element passed with such event is actually attached to the document instance of the page or not.

    Is there an event raised by the Lightstreamer js client library that notifies the client that a record has entered the currently displayed logical page (coming from an undisplayed page, for example because a row has been deleted)?
    such notification does not exists; which kind of error do you get from the jquery plugin? Even if an element is detached from the page it still exists; is it searched on the document by jquery during the animation?


    You may also try to use the MetapushTable (that has an OnRowUpdate callback) or a NonVisualTable (calling its setCommandLogic) binded to a jquery grid (an example based on merge mode is available here: http://www.lightstreamer.com/demo/jqGridDemo/)

  3. #3
    Member
    Join Date
    Jan 2011
    Location
    Redhill
    Posts
    9
    Quote Originally Posted by Mone
    such notification does not exists; which kind of error do you get from the jquery plugin?
    I got:

    Code:
    terminating; too few slides: 0
    which means somehow the class for the slideshow is there, but the data (the divs to be rotated) isn't yet there. This is my bug, not yours

    Quote Originally Posted by Mone
    Even if an element is detached from the page it still exists; is it searched on the document by jquery during the animation?
    This is good news This whole concept of having DOM elements there but detached is new to me, I am not used to programming Javascript But it makes sense. jQuery seems to find only stuff that is in the DOM and visible (found out by having a closer look ). So when something new gets added (and I get onChangingTable for that specific field), I have to stop and start the slideshow, so that the new item also gets animated.

    I am also a bit lost regarding what happens when. I have spend quite some time debugging. For example this seems not to work:

    Code:
    visualUpdateInfo.setStyle('codeshare','pflight slidetarget','pflight slidetarget');
     if (slidenum == 0) { // first slide in dom
      $('.slidetarget').cycle({ timeout: 3000, cleartype: 1, speed: 400 });
     }
    the plugin doesn't seem to be able to "catch" the newly inserted slide.

    If I do:

    Code:
    if (slidenum == 0) { // first slide in dom
         setTimeout(function(){
             $('.slidetarget').cycle({ timeout: 3000, cleartype: 1, speed: 400 });
         }, 1000);
    }													}
    it works better. Sometimes it was working with as little timeout as 50, sometimes 500 is not enough.

    Does this make any sense? Or am I seeing ghosts?

    Quote Originally Posted by Mone
    You may also try to use the MetapushTable (that has an OnRowUpdate callback) or a NonVisualTable (calling its setCommandLogic) binded to a jquery grid (an example based on merge mode is available here: http://www.lightstreamer.com/demo/jqGridDemo/)
    I might do that. The thing is I am using regular HTML for the Lightstreamer table for now, and jQuery only for the animations. But I have already had a quick look at the jqGridDemo, and I might switch to that. Does it make any difference?

    Thanks,
    Emese

  4. #4
    Power Member
    Join Date
    Jul 2006
    Location
    Cesano Maderno, Italy
    Posts
    784
    The jQuery selector finds all slideshow instances, regardless of wether they are being displayed or not. So I guess it is also processing detached DOM elements.
    Not sure about that, hidden elements are different from detached elements; a hidden element is still attached to the DOM and so it can be found navigating the DOM of the page. A detached element is an instance that is not part of the DOM tree of the page so that to access it you need a pointer to it.
    So jquery can't find a detached element unless it cached it before.


    the plugin doesn't seem to be able to "catch" the newly inserted slide.
    that's because the new element is appended to the DOM tree after the notification (the purpose of the onChangingValues is to change the element before it is shown on the page)

    Sometimes it was working with as little timeout as 50, sometimes 500 is not enough.
    this is strange, 1ms should be enough as you only need to execute your code after the append performed in our library. Such append is made in the same "thread" that calls the onChangingValues so that when a setTimeout executes the element should be there (javascript is mono-thread so any setTimeout executes only when the currently-running code exits).
    Btw I don't know what

    means (I have no experience with jquery) so maybe there are other preconditions for it to find the element.
    Btw the onChangingValues gives you a pointer to the element that is going to be appended (or updated). Not sure if (and how) you can pass that to jquery

    But I have already had a quick look at the jqGridDemo, and I might switch to that. Does it make any difference?
    as shown in the demo code you have to push values to the jqGridDemo as there is no automatic binding.
    Also the demo code shows a simple MERGE table, things are just a little bit more complicated with a COMMAND table (eg you have to handle the DELETE updates).
    Btw the NonVisualTable can help you handling it, see the setCommandLogic method for more info.

    HTH

  5. #5
    Member
    Join Date
    Jan 2011
    Location
    Redhill
    Posts
    9
    Quote Originally Posted by Mone
    Not sure about that, hidden elements are different from detached elements; a hidden element is still attached to the DOM and so it can be found navigating the DOM of the page. A detached element is an instance that is not part of the DOM tree of the page so that to access it you need a pointer to it.
    So jquery can't find a detached element unless it cached it before.
    Yes, I have realised that in-between and edited my post in a sneaky way (before you posted your reply )

    Quote Originally Posted by Mone
    that's because the new element is appended to the DOM tree after the notification (the purpose of the onChangingValues is to change the element before it is shown on the page)
    That makes sense.

    Quote Originally Posted by Mone
    Btw I don't know what

    means (I have no experience with jquery) so maybe there are other preconditions for it to find the element.
    It is supposed to be a jQuery selector that will get all element from that DOM that have the class "slidetarget"


    Quote Originally Posted by Mone
    Btw the onChangingValues gives you a pointer to the element that is going to be appended (or updated). Not sure if (and how) you can pass that to jquery
    If you mean the domNode that comes with onChangingValues, I've had a go with it. It contains the row element that is being updated or added. It seemed to me, that when my command is ADD, it contains the row that will be added, but when my command is UPDATE, it has the row with the old values (probably it is the way it should work, just took me time to find out ).

    The docs of onChangingValues say to leave to domNode alone, so maybe it is not a good idea to modify it via jQuery (you can pass the node to jQuery by saying $(domNode).whatever()), that's why I am using setStyle on the updateInfo, even though it is not for hot and cold styles, so I am probably not using it the way is was originally intended.

    BTW is there a mean of telling at the initial load of the client, that client has finished loading the records it is supposed to display? That would be a good time to run jQuery stuff. jQuery has a ready hook, that's where normally jquery stuff goes, it starts when the dom loading is ready. With a lightstreamer page, this is not of much help, as the dom may be ready, but we need engine connection and a whole lot of other stuff before the data is actually displayed. I have tried onEngineReady and some other places based on the docs. For paging (for example to switch to page 2) i use onCurrentPagesChanged() and I check the number of pages available via getCurrentPages(), because I had no clue where else to put the goToPage() call. So I now have:

    Code:
    table.onCurrentPagesChanged = function(){
        //console.log("CurrentPages changed: "+ table.getCurrentPages());
        if( table.getCurrentPages()==2) {
            table.goToPage(2);
      	}
      }
    Is this the right way to seek to page 2?

  6. #6
    Power Member
    Join Date
    Jul 2006
    Location
    Cesano Maderno, Italy
    Posts
    784
    Yes, I have realised that in-between and edited my post in a sneaky way (before you posted your reply )
    Probably I clicked "new reply" and went away for a while

    It is supposed to be a jQuery selector that will get all element from that DOM that have the class "slidetarget"
    so is it possible that the stylesheet is not yet associated with the cell when you call jquery? (hot stylesheet is applied after setColdToHotTime millis )

    It seemed to me, that when my command is ADD, it contains the row that will be added, but when my command is UPDATE, it has the row with the old values (probably it is the way it should work, just took me time to find out ).
    yes that's correct, the row with old values will be updated with new values after the onChangingValues

    The docs of onChangingValues say to leave to domNode alone, so maybe it is not a good idea to modify it via jQuery
    yes that statement was added to avoid to deal with clients removing pieces from an element. As long as you just move pieces around you should not have any problem (anyway, are you using build 1396.4 or 1413?)

    BTW is there a mean of telling at the initial load of the client, that client has finished loading the records it is supposed to display?
    there is a onEndOfSnapshot callback that's called after the initial snapshot of ADD commands, not sure if this is a good hook for your needs

    i use onCurrentPagesChanged() and I check the number of pages available via getCurrentPages(), because I had no clue where else to put the goToPage() call.
    note that onCurrentPagesChanged receives as parameter the number of pages. That said you can call the goToPage method anywhere; the onCurrentPagesChanged is intended to be used to maintain an UI coherent with the number of pages available, but if you find it useful to perform other actions that's not a problem.

  7. #7
    Member
    Join Date
    Jan 2011
    Location
    Redhill
    Posts
    9
    I am using "Lightstreamer Server 3.6 build 1463.2" Moderato edition (for now).

    Do client libs have separate version numbers?

  8. #8
    Member
    Join Date
    Jan 2011
    Location
    Redhill
    Posts
    9

    Cool

    Oh, I see, you have a 4.0 preview Hmm I might try that, as our application is not yet in production, we might as well start with the most up-to-date Lightstreamer (if there are no showstopper issues wrt our data adapters and stuff)

  9. #9
    Power Member
    Join Date
    Jul 2006
    Location
    Cesano Maderno, Italy
    Posts
    784
    yes, any client has its own version / build number;
    the version numbers are included in the folder where you find the library itself.
    On the web client there is also the Lightstreamer.version property that can be checked.

    all the possible compatibility issues are listed in the changelog.

    Any feedback on the preview release is welcome

 

 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT +1. The time now is 06:48 AM.