PDA

View Full Version : How to call native java script functions in extjs



spendkar
11 Jul 2010, 3:55 AM
I need to use few native javascript functions like 'replace()' which replaces a character. When I use those functions I am getting errors in firebug as function not defined. My project is build from Designer.


/*
* File: ItemManagement.js
* Date: Sat May 29 2010 18:28:17 GMT+0530 (India Standard Time)
*
* This file was generated by Ext Designer version xds-1.0.0.10c.
* http://www.extjs.com/products/designer/
*
* This file will be generated the first time you export.
*
* You should implement event handling and custom methods in this
* class.
*/

ItemManagement = Ext.extend(ItemManagementUi, {
initComponent: function() {
ItemManagement.superclass.initComponent.call(this);

this.matrixGrid.on('afteredit', this.computeSellPrice, this);



},
computeSellPrice: function (event)
{
var rec = event.record;
var field = event.field;
var val = event.value;
var calc = (rec.data.PROFIT_MARGIN * val)/100;
calc = calc.replace('%','');

if (field == 'COST') { rec.set('SELL_PRICE', calc); }

if (field == 'PROFIT_MARGIN') { rec.set('SELL_PRICE', calc);}


},

});

Skay
11 Jul 2010, 4:24 AM
try to convert your calc variable to string data type, then call replace function for string variable.