@Mone, Wrote: we're valuating to include them in our next release, btw in any case, if we add such getters, note that, for "null,null"-constructed tables, you can't use them before the addTable call is issued as that call is where the table object is bound to it's html counterpart so that it can read it's group and schema from the DOM.
Oh, yes, of course, I missed the call to "PushPage.addTable()" in my few example lines, thanks for the hint.
Nevertheless I think the getters should be "usable" even before "addTable()", i.e. they would just return "null". If you say "..can't use them before.." it sounds as if that would result in an error, so I just wanted to clarify this point.
Furthermore, I can use
Table.getId() to find out if the table has been added (i.e. is in running state), so I could do something like[SYNTAX="JS"]var myOverwritableTable = new OverwriteTable(null, null, 'MERGE');
var myItemArray = null;
var myFieldArray = null;
...
//addTable() might(!!) be called inbetween
...
getGroupAndSchemaIfTableIsRunning();
...
function getGroupAndSchemaIfTableIsRunning() {
if (myOverwritableTable.getId() != null) {
// table is in running state, "addTable()" has been called
var myItemArray = myOverwritableTable.getGroup();
var myFieldArray = myOverwritableTable.getSchema();
} else {
//schedule next check
window.setTimeout("getGroupAndSchemaIfTableIsRunning()",2500);
}
}
[/SYNTAX]IMHO it would be even better if there were dedicated callback interfaces similar to "onStart()", something in the line of "onAdd()" and "onRemove()", because
if I'm not mistaken "onStart()" is not necessarily called right away after the "addTable()"-call finishes, but only after the the Lightstreamer server has received and answered the subscription-request. This would mean that "onStart()" wouldn't be called if there's a network problem, even though the HTML cells have been processed by the "addPage()"-call, so the table-objects knows which fields and items the table contains.
And as far as I can tell there's no way at the moment to get notified if a table is removed via "removeTable()", not even a counterpart to "onStart()" like "onStop()".
But if there were "onAdd()" and "onRemove()" callbacks I could just use them like this :Smile_Ah: SYNTAX="JS"]var myOverwritableTable = new OverwriteTable(null, null, 'MERGE');
myOverwritableTable.onAdd = function() {
var myItemArray = myOverwritableTable.getGroup();
var myFieldArray = myOverwritableTable.getSchema();
};
myOverwritableTable.onRemove = function() {
var myItemArray = null;
var myFieldArray = null;
};[/SYNTAX]..and I'm done.
By the way, I just noticed that the "onStart()"-callback has no parameter - wouldn't it be a good idea to hand a reference to the table-object to the called function, i.e. change the "onStart()"-definition from
void onStart()
to
void onStart(<Table> tableSpec)
That way you could use one central function to handle all the "onStart()"-callbacks, and choose different actions depending upon the table id or even the class of the table (by using "getClassName()") :Smile_Ah: SYNTAX="JS"]function myOnStartHandler(tableSpec) {
switch (tableSpec.getClassName()) {
case "OverwriteTable":
if (tableSpec.getId() == 'myTableName') {
...
} else {
...
}
break;
case "DynaScrollTable":
...
break;
}
}
...
myOverwritableTable.onStart = myOnStartHandler;
...[/SYNTAX]At the moment you have to specify separate functions as there's no indication for which table instance the "onStart()" callback has been called.
Oh, there's one other question I have regarding "addTable()" and "removeTable()" (sorry, quite a lot for one post, I know). When I call "addTable()" the first time, the library scans the DOM for the HTML elements to associate the table to. But when I do something like this over the lifetime of the page :Smile_Ah: SYNTAX="JS"]var myOverwritableTable = new OverwriteTable(null, null, 'MERGE');
...
//first call to 'addTable()'
myPushPage.addTable(myOverwritableTable, 'myTableName');
...
myPushPage.removeTable('myTableName');
...
//second call to 'addTable()'
myPushPage.addTable(myOverwritableTable, 'myTableName');
...
[/SYNTAX]..what happens during the second call to 'addTable()'? Does the Lightstreamer library remember that it already searched through the DOM for that particular table identifier, or is the DOM-search repeated? This would be good to know for the use-case of manipulating the DOM via JavaScript, i.e. adding another table row dynamically..