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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • harry.viet@gmail.com

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

    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.a sp',
    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(t his.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,oRo w) {
    this.options.co lumns.eachSlice (1, function(column s) {
    var oTd = document.create Element('td');
    oRow.appendChil d(oTd);
    oTd.align = columns.pluck(' align');
    Cellfield =
    columns.pluck(' field').toStrin g().toLowerCase ();
    Celltype =
    columns.pluck(' type').toString ().toLowerCase( );
    Cellformat = columns.pluck(' format');
    CellText =
    getXMLNodeValue (rootNode[nr].getElementsByT agName(Cellfiel d));

    this.formatCell (CellText,CellT ype,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?
  • Thomas 'PointedEars' Lahn

    #2
    Re: How to send collection of parameters as options to an formatfunction

    On 5 Jun., 12:24, harry.v...@gmai l.com wrote:
    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(t his.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,oRo w) {
    this.options.co lumns.eachSlice (1, function(column s) {
    [...]
    Cellformat = columns.pluck(' format');
    [...]
    >
    this.formatCell (CellText,CellT ype,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.co lumns.eachSlice ===
    Array.prototype .eachSlice, columns.pluck === Array.prototype .pluck,
    and Function.protot ype.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

    Comment

    • jdalton

      #3
      Re: How to send collection of parameters as options to an formatfunction

      Hello Harry,

      Please post your question on the Prototype user list:


      You may need to post more code snippets or an example html file as
      well :).

      - JDD

      Comment

      • Thomas 'PointedEars' Lahn

        #4
        Re: How to send collection of parameters as options to an formatfunction

        jdalton wrote:
        Hello Harry,
        Don't call me Jer^W Harry.[tm]


        PointedEars
        --
        Use any version of Microsoft Frontpage to create your site.
        (This won't prevent people from viewing your source, but no one
        will want to steal it.)
        -- from <http://www.vortex-webdesign.com/help/hidesource.htm>

        Comment

        Working...