XPages:在dojo网格中形成货币

时间:2015-12-14 20:12:59

标签: javascript gridview dojo xpages

当我尝试在dojo网格中使用onApplyCellEdit()计算两个单元格时,我得到NAN错误,特别是当是一个分数条目时,下面是格式化函数:

 function formatCurrency(value, rowIndex, cell){
    if(value){
        var price =dojo.currency.format(value,{currency:"EUR", locale: 'de-de'});;
        return price;
    }
}

在我得到的onClientLoad事件上:

var grid = dijit.byId('#{id:grid}');
if(grid){
    dojo.require("dojo.number");
    var oldVal 
    grid.onStartEdit = function(inCel, inRow){
        var store = dataGrid.store;
        var item = dataGrid.getItem(inRow);
        oldVal = store.getValue(item, inCel.field ); 

    };

      grid.onApplyCellEdit = function( inVal, inRow, inFld ){
        var store = dataGrid.store;
        var item = dataGrid.getItem(inRow);
        if(inFld =="amount" || inFld =="quantity"){
            var inputPrice =store.getValue(item,"amount")
            var quantity = store.getValue(item,"quantity");
            oldVal = dojo.number.format(oldVal,{locale: 'de-de'});
            if (inVal== oldVal) {               
                console.log('No Change Made'); 
            }else{ 
                price = dojo.number.parse(inputPrice,{locale: 'de-de'});
                total = (quantity * price);

                store.setValue(item, 'amount', price);
                store.setValue(item, 'totalAmount', total);
                console.log('edit applied'); 

            } 
        }
    };
}

我如何解析和格式化单元格以接收locale: 'de-de'并将单位格式显示为欧元货币。

0 个答案:

没有答案