:: Forum >>

How can I set 'array' in parameter ?? Is it possable??

I need to make the parameter( array type )

Or another idea??

plusay
Thursday, November 4, 2004
Sure, here are two ways that do it (could be more) sinle and multiple lines.
(I can not imagine what's your array for, so I use it as Grid-Data, but for this pourpose the easier way is the "normal CSV"), I take Alex's basic sample , need to copy any of this line/s and name it "array.csv" into .../examples/data folder.
Hope this give some help

//******************
"var CSVData = [['MSFT','Microsoft Corporation', '314,571.156', '32,187.000', '55000']]"
"CSVData.push(['ORCL', 'Oracle Corporation', '62,615.266', '9,519.000', '40650'])"
"CSVData.push(['SAP', 'SAP AG (ADR)', '40,986.328', '8,296.420', '28961'])"
"CSVData.push(['CA', 'Computer Associates Inter', '15,606.335', '3,164.000', '16000'])"
//******************
OR
//*****************
"var CSVData = [['MSFT','Microsoft Corporation', '314,571.156', '32,187.000', '55000'],['ORCL', 'Oracle Corporation', '62,615.266', '9,519.000', '40650'],['SAP', 'SAP AG (ADR)', '40,986.328', '8,296.420', '28961'],['CA', 'Computer Associates Inter', '15,606.335', '3,164.000', '16000']];"
//************************

<html>
<head>
<title>ActiveWidgets Grid :: Examples</title>
<style> body, html {margin:0px; padding: 0px; overflow: hidden;} </style>

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

<!-- grid format -->
<style>
.active-controls-grid {height: 100%; font: menu;}

.active-column-0 {width: 80px;}
.active-column-1 {width: 200px;}
.active-column-2 {text-align: right;}
.active-column-3 {text-align: right;}
.active-column-4 {text-align: right;}

.active-grid-column {border-right: 1px solid threedlightshadow;}
.active-grid-row {border-bottom: 1px solid threedlightshadow;}
</style>

</head>
<body>
<script>

var lineread = [];
var Codesentence ="";
var myData = [];

var myColumns = [
"Ticker", "Company Name", "Market Cap.", "$ Sales", "Employees"
];

// create ActiveWidgets data model - text-based table
var codetable = new Active.Text.Table;

// create javascript object
var obj = new Active.Controls.Grid;

//LOADING PLEASE WAIT
obj.setStatusProperty("code", "loading");

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

var codeResponse = codetable.response;
codetable.response = function(data){
codeResponse.call(codetable, data);
CodeTableLen=codetable.getCount();

// READ THE LINES INTO THE CSV-PARAMETER FILE (1 COLUMN ) ( ONLY ONE PARAM. PER LINE)
// ANYTHING BETWEEN DOUBLE-QUOTES-MARK "---"
for(var x=0; x< CodeTableLen; x++) { lineread.push([codetable.getText( x, 0)]);
Codesentence = lineread[x][0];
eval(Codesentence);
}
//AS ANY ARRAY DEFINED AS PARAMETER ONLY EXIST INTO THE MAIN FUNCTION , NEEDS
// TO BE CLONED INTO OTHER ARRAY DEFINED PREVIOUSLY ( OUTSIDE MAIN FUNCTION codetable.response = function(data){---)
myData=CSVData;

CSVData=null;

//// let the browser paint the grid
window.setTimeout(function(){
////clear status code
obj.setStatusProperty("code", "");
obj.refresh();
}, 0);

}

codetable.request();

// set headers width/height
obj.setRowHeaderWidth("28px");
obj.setColumnHeaderHeight("20px");

// set number of rows/columns
obj.setRowProperty("count", 3);
obj.setColumnProperty("count", 5);

// provide cells and headers text
obj.setDataProperty("text", function(i, j){return myData[i][j]});
obj.setColumnProperty("text", function(i){return myColumns[i]});


// set click action handler
obj.setAction("click", function(src){window.status = src.getItemProperty("text")});

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

</script>
</body>
</html>
Carlos
Thursday, November 4, 2004
Upsss... Sorry, you mean obj , or CSV parameter ?
Carlos
Thursday, November 4, 2004
Thanks your Answer!!

but I think not csv parameter..

I use language is JSP.
I have a value(array type) from grid. And I want to send a Value to server for update, delete or insert.
plusay
Friday, November 5, 2004

This topic is archived.


Back to support forum

Forum search