Results 1 to 7 of 7

Hybrid View

  1. #1
    Senior Member
    Join Date
    Oct 2007
    Location
    HoChiMinh
    Posts
    69
    Thanks Dario, like u said : extra field 16, If I change the field to 116 :

    --- stocklist demo, default.html ----

    function updateItem(item, updateInfo) {
    if (updateInfo == null) {
    return;
    }
    if (updateInfo.isValueChanged(3)) {
    var val = updateInfo.getNewValue(3);
    if (val.indexOf("-") > -1) {
    updateInfo.addField(116,imgDown); } else {
    updateInfo.addField(116,imgUp);
    }
    }
    ...
    }

    I should also change :

    -- stocklist demo code, default.html -----

    <script>
    for (var i = 1; i <= 15; i++) {
    var suff = (i % 2 == 1) ? "A" : "B";
    document.write('<tr class="lscold'+suff+'">');
    document.write('<td nowrap style="text-align: left"><div class="stockname'+suff+'" source="lightstreamer" table="1" item="'+i+'" field="12">Loading...</div></a></td>');
    document.write('<td><div source="lightstreamer" table="1" item="'+i+'" field="1">-</div></td>');
    document.write('<td><div source="lightstreamer" table="1" item="'+i+'" field="116">-</div></td>');

    }

    </script>

    Is it correct?

    And extra field 14, if i change the field to 114, I have to do :

    ---- stock list demo code, default.html ----

    function updateItem(item, updateInfo) {
    ...
    if (oldLast == null) { //first update for this item
    updateInfo.addField(114,greenColor,true); //no fade for snapshot
    if (doFade) {
    updateInfo.addField(15,"OFF",true);
    }
    } else if (updateInfo.isValueChanged(1)) {
    //at least second update
    if (oldLast > updateInfo.getNewValue(1)) {
    updateInfo.addField(114,redColor,true);
    } else {
    updateInfo.addField(114,greenColor,true);
    }
    if (doFade) {
    updateInfo.addField(15,"ON",true);
    }
    }

    and changed :

    function formatValues(item, itemUpdate) {
    ....
    //choose the backgroundColor
    var backC = (item % 2 == 1) ? "#eeeeee" : "#ddddee";
    var backH = itemUpdate.getServerValue(114);
    itemUpdate.setRowAttribute(backH,backC,"background Color");
    }


    -----------

    Is it correct ?
    --------------------
    But in my code, i have a global variable declaration, and extra field identified by names, not by numbers, something like this :

    ////////////////Global var declaration
    var group = ["item1", "item2", "item3", "item4","item5", "item6", "item7", "item8","item9", "item10", "item11", "item12","item13", "item14", "item15", "item16", "item17", "item18", "item19", "item20", "item21", "item22", "item23", "item24", "item25", "item26", "item27", "item28", "item29", "item30"];

    var schema = ["last_price", "time", "pct_change","bid1", "bid2", "bid3", "bid1vol", "bid2vol", "bid3vol", "ask1","ask2", "ask3", "ask1vol", "ask2vol", "ask3vol", "min", "max","ref_price", "open_price", "stock_name", "ceiling", "floor", "lastVal", "lastVol", "close_price", "close_vol"];

    var newTable = new OverwriteTable(group, schema,"MERGE");

    -----

    <script>
    for (var i = 1; i <= 30; i++)
    {
    var suff = (i % 2 == 1) ? "A" : "B";

    document.write('<tr class="lscold'+suff+'">');
    document.write('<td>&nbsp;</td>');
    document.write('<td class="stockname'+suff+'"><div source="lightstreamer" table="list" item="'+i+'" field="stock_name"> - </div></td>');
    document.write('<td><div source="lightstreamer" table="list" item="'+i+'" field="ref_price"> - </div></td>');

    ...
    }
    </script>

    ---
    I can change in updateItem() function something like this?

    function updateItem(item, updateInfo) {
    if (updateInfo == null) {
    return;
    }
    if (updateInfo.isValueChanged("pct_change")) {
    var val = updateInfo.getNewValue("pct_change");

    if (val.indexOf("-") > -1)
    {
    updateInfo.addField("pct_change",imgDown); }
    else
    {
    updateInfo.addField("pct_change",imgUp);
    }
    ...
    }


    I mean I can used the name in updateItem.addField() function, not using the numbers?

  2. #2
    Administrator
    Join Date
    Jul 2006
    Location
    Milan
    Posts
    1,091
    Yes, you can. Provided that an array is used to define the "schema", you can use names as well as numbers to identify the subscribed fields and this also holds for extra fields.

    Actually, the StockList demo front-end code is still based on the older number-based syntax and this makes it less easy to extend it. Hence, the number references to the extra fields had to be changed. Note that you should rename extra field 15 (into 115 or some custom name) as well, though it is never used with the current front-end configuration.

    Moreover, as you added your custom fields in the middle of the original field list, also the numeric references to the subscribed field numbers in the "updateItem" and "onChangingValues" method may need to be changed (if you need to preserve these event handlers at all). Moving to field-name syntax surely is the best choice.

    Dario

  3. #3
    Senior Member
    Join Date
    Oct 2007
    Location
    HoChiMinh
    Posts
    69
    Thanks Dario very much. I will try.

    Have a nice days.

 

 

Similar Threads

  1. Replies: 2
    Last Post: December 24th, 2010, 07:51 AM
  2. how to add the item into eventData
    By tuongkha in forum Adapter SDKs
    Replies: 9
    Last Post: January 9th, 2008, 09:51 AM

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 03:50 AM.