-
January 23rd, 2007, 04:06 PM
#1
NonVisualTable with COMMAND mode
Usually an item subscribed in COMMAND mode is displayed through a DynaMetapushTable. However if your application directly takes care of the view, then a NonVisualTable can be employed.
This post briefly shows how to modify the Portfolio Demo in order to use a NonVisualTable.
The last lines of the PortfolioDemo index.html page will become:
Code javascript:
/////////////////////////////////table handler
var table = new NonVisualTable("portfolio", schema, "COMMAND");
table.setSnapshotRequired(true);
// the following settings were used to control the behaviour
// of the DynaMetapushTable; with NonVisualTable, all
// formatting, paging and sorting stuff, if required,
// should be managed by custom code
// table.setPushedHtmlEnabled(false);
// table.setClearOnDisconnected(true);
// table.onChangingValues = formatValues;
// table.setMaxDynaRows("unlimited");
// table.setMetapushFields(2, 1);
// table.setMetapushSort(3, direction);
table.onItemUpdate = myUpdateHandler;
lsPage.addTable(table, "info");
Some code in the original index.html is no longer needed, because it is related to the DynaMetapushTable. In particular, the <TABLE> element has to be replaced with the custom GUI object and the "changeSort" and "formatValues" functions (together with their helper functions: "formatTime", "formatDecimal" and "convertCommaToDot") can be removed.
A new "myUpdateHandler" function, on the other hand, is now needed. It may be coded in the following way:
Code javascript:
function myUpdateHandler(item, updateValues) {
// item should be always 1
// updateValues is of type "UpdateItemInfo"
// (see the JSDocs for details)
var commandField = 2;
// the "command" field is the second field
// on the specified schema
var keyField = 1;
// the "key" field is the first field
// on the specified schema
var command = updateValues.getNewValue(commandField);
var key = updateValues.getNewValue(keyField);
if (command == "ADD") {
addRowOnMyGUI(key, updateValues);
} else if (command == "UPDATE") {
updateRowOnMyGUI(key, updateValues);
} else if (command == "DELETE") {
deleteRowOnMyGUI(key);
}
}
The new "addRowOnMyGUI", "updateRowOnMyGUI" and "deleteRowOnMyGUI"
functions should be added. The supplied "updateValues" object can be used in order to find the current values of the subscribed fields ("stock", "price", "qty", "cval" and "time"), by invoking on it the "getNewValue" method, with parameter 3, 4, 5, 6 or 7.
-
June 17th, 2009, 03:01 AM
#2
Hi Alessandro, I have question here. What if I want only certain items to be display (something like grouping)?
For example if the data pushed contains item1,item2,item3; and I want only item1 and item3 to be display. Can it be done in this way? How to do it?
Is it I have to subscribe an item group to the table:
var group = "item1 item3";
var table = new NonVisualTable(group, schema, "COMMAND");
table.setSnapshotRequired(true);
table.onItemUpdate = myUpdateHandler;
lsPage.addTable(table, "info");
Please correct me if I'm wrong. Thanks.
-
June 17th, 2009, 11:50 AM
#3
Hi,
From what you say, it seems you don't need COMMAND mode, but just a plain MERGE mode, where you can specify the group you need to subscribe to.
The group name can be either a space-separated list of items names or a totally symbolic name, which will be expanded by your custom Metadata Adapter.
Similar Threads
-
By jonasby in forum Client SDKs
Replies: 2
Last Post: June 17th, 2011, 09:21 AM
-
By Pradeep Chahal in forum Adapter SDKs
Replies: 4
Last Post: September 3rd, 2010, 12:08 PM
-
By Pradeep Chahal in forum Adapter SDKs
Replies: 1
Last Post: February 24th, 2010, 09:52 AM
-
By Pradeep Chahal in forum Client SDKs
Replies: 2
Last Post: February 15th, 2010, 10:20 AM
-
By atnemeth in forum Client SDKs
Replies: 3
Last Post: May 19th, 2008, 10:19 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 03:19 AM.
Bookmarks