How to send collection of parameters as options to an format function

H

harry.viet

I use the prototype library and create a class that builds a grid
using some parameters as mentioned below.
Everything is working but only the parameters for Number formatting

var gridopts = {
iPageSize : 100,
dataSource : '../data/ledgergetdata.asp',
dataPars : { acct_type : '2' },
columns : [{ name: 'nummer', field : 'acctnr' , width:
'10%' , align: 'left', type: 'str', filter: true },
{ name: 'description', field : 'desc', width: '60%' ,
align: 'left', type: 'str', filter: true },
{ name: 'debit', field : 'debit', width: '10%' , align:
'right', type: 'num', format: [{ShowZero:false,DecPlaces:
2}] },
{ name: 'credit', field : 'credit', width: '10%' ,
align: 'right', type: 'num' },
{ name: 'balance', field : 'balance', width: '10%' ,
align: 'right', type: 'num', format: [{ShowZero:true,DecPlaces:2}] }]
}

With the syntax Object.extend(this.options, options || {}) in the grid
class I got all the parameter.
Soo far no problem.
When I create the tablecells in my grid class there is a function
like:

createCells: function(nr,oRow) {
this.options.columns.eachSlice(1, function(columns) {
var oTd = document.createElement('td');
oRow.appendChild(oTd);
oTd.align = columns.pluck('align');
Cellfield =
columns.pluck('field').toString().toLowerCase();
Celltype =
columns.pluck('type').toString().toLowerCase();
Cellformat = columns.pluck('format');
CellText =
getXMLNodeValue(rootNode[nr].getElementsByTagName(Cellfield));

this.formatCell(CellText,CellType,Cellformat,Cellfield,oTd);
}.bind(this))
},

The problem:
I should expect that the var Cellformat contains the array like
[{ShowZero:false,DecPlaces:2}]
I would send this to the this.formatCell function to use it as
parameters to create the format to display.
The var Cellformat gives 'undefined'
Could anybody give me a hint?
 
T

Thomas 'PointedEars' Lahn

I use the prototype library

My sincere condolences.
and create a class

There are no classes there.
that builds a grid using some parameters as mentioned below.
Everything is working but only the parameters for Number formatting

var gridopts = {
[...]
columns : [{
[...]
}]
}

With the syntax Object.extend(this.options, options || {}) in the grid
class I got all the parameter.

Your posted code does not contain a definition of the `options'
identifier. However, as both the object referred to by `gridopts' and
the object referred to by `this.options' appear to have a `columns'
property, I will assume

this.options = gridopts;

in the following.
Soo far no problem.
When I create the tablecells in my grid class there is a function
like:

createCells: function(nr,oRow) {
this.options.columns.eachSlice(1, function(columns) {
[...]
Cellformat = columns.pluck('format');
[...]

this.formatCell(CellText,CellType,Cellformat,Cellfield,oTd);
}.bind(this))

},

The problem:
I should expect that the var Cellformat contains the array like
[{ShowZero:false,DecPlaces:2}]
I would send this to the this.formatCell function to use it as
parameters to create the format to display.
The var Cellformat gives 'undefined'

Your problem is caused by an improper use of or a bug in the
Prototype.js API, particularly one or more of the augmented (not built-
in) Object.extend(), this.options.columns.eachSlice ===
Array.prototype.eachSlice, columns.pluck === Array.prototype.pluck,
and Function.prototype.bind() methods.
Could anybody give me a hint?

The Prototype.js support area is over there --> http://prototypejs.org/


Ceterum censeo Prototype.js esse delendam.

PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top