3.0.5

Ok, I am a complete muppet can someone help me.

OK. What I want to do is to have a live updating spreadsheet from a vendor data feed to display its contents on our intranet.

Eventually, if possible, I would like to incorporate a few pages into our CMS system - "Joomla".

Can anyone hold my hand from start to finnish since I am not a programmer and need help!
Complete Muppet.
January 21,
I forgot to mention:
My test rig is on a small network Windows box running excel and a Centos 4.4 box running PHP/Apache and MySql.
Data at times may change very quickly as often as 4 times a second under throttled conditions and there are about 50 rows with at least 5 cells per row in excel. In the rows probably to start only 3 cells need to dynamicly update. Bid/Ask and Last and this will be numerical data originating from excel.

Thanks a lot in advance.

Complete Muppet.
January 22,
This is great! I can answer my own questions here -

So... I have this kind of working now.

My live data in excel
save to csv with a vba macro every 10 seconds

Have the grid working but it doesn't auto refresh at all.
table.request(); seems to do nothing.

I can get the page to refesh with a manual button as you can see
in the script which was found in a locked filing cabinet in the basement
of this forum.

How can I get this puppy to update either automatically or at a regular refresh period like 5 seconds. Here's the code that I have mangled.

<html>
<head>

<title>ActiveWidgets Grid :: Examples</title>

<!-- ActiveWidgets stylesheet and scripts -->
<link href="../../runtime/styles/aqua/aw.css" rel="stylesheet" type="text/css" ></link>
<script src="../../runtime/lib/aw.js"></script>

<!-- grid format -->
<style>
.aw-grid-control {height: 100%; width: 70%; font: menu;}

.aw-column-0 {width: 80px;}
.aw-column-1 {width: 100px; background-color: threedlightshadow;}
.aw-column-2 {text-align: center;}
.aw-column-3 {text-align: center;}
.aw-column-4 {text-align: center;}

.aw-grid-cell {border-right: 1px solid threedshadow;}
.aw-grid-row {border-bottom: 1px solid threedlightshadow;}
</style>
</head>
<body>
<script>

// create ActiveWidgets data model - CSV text table
var table = new AW.CSV.Table;

// provide data URL - plain text comma-separated file
table.setURL("../data/companies.csv");

// start asyncronous data retrieval
table.request();

// define column labels
var columns = ["Ticker", "Product", "Last", "Bid", "Ask"];

// create ActiveWidgets Grid javascript object
var obj = new AW.UI.Grid;

// provide column labels
obj.setHeaderText(columns);

// number of columns
obj.setColumnCount(5);

// enable row selectors
obj.setSelectorVisible(true);
obj.setSelectorText(function(i){return this.getRowPosition(i)});
obj.setSelectorWidth(25);

// define data formats
var str = new AW.Formats.String;
var num = new AW.Formats.Number;

// set data formats
obj.setCellFormat([str, str, num, num, num]);

// enable row selectors
obj.setSelectorVisible(true);
obj.setSelectorText(function(i){return this.getRowPosition(i)+1});
obj.setSelectorWidth(25);

// set row selection
obj.setSelectionMode("single-row");

// assign external 'data model'
obj.setCellModel(table);

// write grid html to the page
document.write(obj);

var button = new AW.UI.Button;
button.setControlText("Refresh Now!");
button.onClick = function() {
table.request();
}
document.write(button);


function load(url){
table.setURL(url);
table.request();
}

function updateTable(){
table.request();
obj.refresh();
gridTable.request();
grid.refresh();
}


</script>


</body>
</html>
Complete Muppet
January 24,
You can add random parameter to the url to ensure that the data file is not cached -

function loadData(){
    var url = "../data/companies.csv?" + Math.random();
    table.setURL(url);
    table.request();
    window.setTimeout(loadData, 5000); // repeat after 5 sec
}

loadData();
Alex (ActiveWidgets)
January 24,
Thank you Alex.

That works great. However, during the actual instant of update there is a
little screen flicker which I would like to surpress.

On Firefox the vertical and horizontal scroll bars appear momentarily then dissapear.
On IE6 Thw top row countaining the column headers flickers.

Is there any way to surpress that effect, so that only the cell updates show please?

Many thanks and regs

Complete Muppet
January 24,
Here is more complex approach - keeping the source data table separate from the grid and only copy the changed cells.

var obj = new AW.UI.Grid;
obj.setColumnCount(5);
document.write(obj);

var table = new AW.CSV.Table;
table.response1 = table.response; 
table.response = function(text){
    this.response1(text);
    var rows = this.getCount();
    if (rows != obj.getRowCount()) {
        obj.setRowCount(rows);
        obj.refresh();
    }
    var columns = obj.getColumnCount();

    for (var r=0; r<rows;r++){
        for (var c=0; c<columns;c++){
            var v = this.getData(c, r);
            if (v != obj.getCellText(c, r)){
                obj.setCellText(v, c, r);
                highlight(c, r);
            }
        }
    }

    function highlight(c, r){
        var e = obj.getCellTemplate(c, r).element();
        if (e) {
            e.style.color = "red";
            window.setTimeout(function(){
                e.style.color = "black";
                e = null;
            }, 1000);
        }
    }

    window.setTimeout(function(){
             var url = "../data/companies.csv?" + Math.random();
             table.setURL(url);
             table.request(); 
    }, 5000);
}

var url = "../data/companies.csv?" + Math.random();
table.setURL(url);
table.request();
Alex (ActiveWidgets)
January 25,
Hello Alex. thanks very much. I have the new code you posted working.
It has cured the flashing problem on both browsers and because the updates are based on the actual changes it "feels" more lively.

Also your prediction that "red" flash on update would be useful, has certainly saved me time. Great, thanks very much indeed.

Now, the remaining hurdle is that I want this to display also on mobile phone wap browsers. Since most real time applications on mobile phones user java applets, it may be beyond the capability of AW. i hope not, since what I see I like. Now I have some practice it is easier to configure than I first thought.

Best regards

Tee
Tee the Complete Muppet
January 25,
No, AW has nothing to do with java applets. So the only way for AW code to work on a mobile phone is to have a standard web browser there. I guess this is the current trend with the new models anyway - to use WebKit or Opera-based browser. So maybe AW will work on mobiles very soon :-)
Alex (ActiveWidgets)
January 26,
Bit off topic - sorry!

Yes the browsers are usually Opera or Openwave. Here in Japan most of the phones are all java equipped and very high tech. Mine is a Sanyo with BREW not much help for what I am trying to do. It does have a slew of other goodies, Digital TV, FM radio, mp3 , Navigation, 2megapix camera.
etc etc

Thanks for all your help.

Will be back.

Regards

Tee!
January 27,

This topic is archived.

See also:


Back to support forum