-
January 10th, 2008, 02:28 AM
#1
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> </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?
-
January 10th, 2008, 08:20 AM
#2
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
-
January 10th, 2008, 09:26 AM
#3
Thanks Dario very much. I will try.
Have a nice days.
Similar Threads
-
By hungtt in forum Adapter SDKs
Replies: 2
Last Post: December 24th, 2010, 07:51 AM
-
By tuongkha in forum Adapter SDKs
Replies: 9
Last Post: January 9th, 2008, 09:51 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
All times are GMT +1. The time now is 04:14 AM.
Bookmarks