|
没有用过在grid中的,有在文本框中用过,发上来,供你参考一下吧。
//用于客端自动计算 销售金额
public String GetTxtChange()
{
String scriptStr="";
try
{
scriptStr =String.Concat(
" var txtMagnitude = Ext.getCmp('" + MDFpsGrid1.GetEditControlDetail("数量").ClientID + "');\n" ,
"var txtSellPrice = Ext.getCmp('" + MDFpsGrid1.GetEditControlDetail("销售价格").ClientID + "');\n" ,
"var txtAmount = Ext.getCmp('" + MDFpsGrid1.GetEditControlDetail("销售金额").ClientID + "');\n" ,
"txtAmount.setValue(parseFloat(txtMagnitude.getValue()) * parseFloat(txtSellPrice.getValue()));\n",
"var txtCostPrice = Ext.getCmp('" + MDFpsGrid1.GetEditControlDetail("成本价格").ClientID + "');\n",
"var txtCostAmount = Ext.getCmp('" + MDFpsGrid1.GetEditControlDetail("成本金额").ClientID + "');\n" ,
"txtCostAmount.setValue(parseFloat(txtMagnitude.getValue()) * parseFloat(txtCostPrice.getValue()));\n"
);
}
catch (Exception ex)
{
scriptStr = "";
}
return scriptStr;
}
public String GetOnReady()
{
String scriptStr = "";
try
{
scriptStr =String.Concat(
"var txtMagnitude = Ext.getCmp('" + MDFpsGrid1.GetEditControlDetail("数量").ClientID + "')\n" ,
"var txtSellPrice = Ext.getCmp('" + MDFpsGrid1.GetEditControlDetail("销售价格").ClientID + "');\n" ,
"var txtCostPrice = Ext.getCmp('" + MDFpsGrid1.GetEditControlDetail("成本价格").ClientID + "');\n" ,
"Ext.EventManager.addListener(txtMagnitude.id, 'change', txtChange);\n" ,
"Ext.EventManager.addListener(txtMagnitude.id, 'keypress', txtChange);\n" ,
"Ext.EventManager.addListener(txtSellPrice.id, 'change', txtChange);\n",
"Ext.EventManager.addListener(txtSellPrice.id, 'keypress', txtChange);\n",
"Ext.EventManager.addListener(txtCostPrice.id, 'change', txtChange);\n",
"Ext.EventManager.addListener(txtCostPrice.id, 'keypress', txtChange);\n"
);
}
catch (Exception ex)
{
scriptStr = "";
}
return scriptStr;
} |
|