您好我有一个ext js数据网格,用于排序和过滤已经正常工作,但用户发现了一个错误,我无法弄清楚它是什么?
其中一个itemID(产品)看起来像这样= 98694E130,但显示为986940000000000。
你能帮忙吗 - 让我知道我是否需要发布代码。
提前致谢
代码如下:...
var material_colModel = new Ext.grid.ColumnModel([
{header: "#JSStringFormat(lang_rb.material)#", width: 75, sortable: true, dataIndex: "MATERIAL", filter: {}},
{header: "#JSStringFormat(lang_rb.materialDescription)#", width: 200, sortable: true, dataIndex: 'MATERIALDESCRIPTION', filter: {}},
{header: "#JSStringFormat(lang_rb.EANcode)#", width: 100, sortable: true, dataIndex: 'EANCODE', filter: {}},
{header: "#JSStringFormat(lang_rb.SKU)#", width: 60, sortable: true, dataIndex: 'SKU', filter: {}},
{header: "#JSStringFormat(lang_rb.UPC)#", width: 50, sortable: false, dataIndex: 'UNITSPERCARTON', align: 'right', css: 'background-color: ##f9f9f9;'},
{header: "#JSStringFormat(lang_rb.price)# (#currencySymbol#)", width: 50, sortable: false, dataIndex: 'UNITPRICE', align: 'right', renderer: fmtValue, css: 'background-color: ##f9f9f9;'},
{header: "#JSStringFormat(lang_rb.productClassificationCode)#", width: 50, sortable: true, hidden: false, dataIndex: 'PRODUCTCLASSIFICATIONCODE', filter: {}},
{header: "#JSStringFormat(lang_rb.productClassification)#", width: 175, sortable: true, hidden: false, dataIndex: 'PRODUCTCLASSIFICATIONDESC', filter: {}},
{header: "#JSStringFormat(lang_rb.superCategoryCode)#", width: 50, sortable: true, hidden: false, dataIndex: 'SUPERCATEGORYCODE', filter: {}},
{header: "#JSStringFormat(lang_rb.superCategory)#", width: 175, sortable: true, hidden: false, dataIndex: 'SUPERCATEGORYDESC', filter: {}},
{header: "#JSStringFormat(lang_rb.categoryCode)#", width: 50, sortable: true, hidden: false, dataIndex: 'CATEGORYCODE', filter: {}},
{header: "#JSStringFormat(lang_rb.category)#", width: 175, sortable: true, hidden: false, dataIndex: 'CATEGORYDESC', filter: {}},
{header: "#JSStringFormat(lang_rb.internalClassificationCode)#",width: 50, sortable: true, hidden: false, dataIndex: 'INTERNALCLASSIFICATIONCODE', filter: {}},
{header: "#JSStringFormat(lang_rb.internalClassification)#", width: 175, sortable: true, hidden: false, dataIndex: 'INTERNALCLASSIFICATIONDESC', filter: {}},
{header: "#JSStringFormat(lang_rb.brandCode)#", width: 50, sortable: true, hidden: false, dataIndex: 'BRANDCODE', filter: {}},
{header: "#JSStringFormat(lang_rb.brand)#", width: 125, sortable: true, hidden: false, dataIndex: 'BRANDDESC', filter: {}},
{header: "#JSStringFormat(lang_rb.familyBrandCode)#", width: 50, sortable: true, hidden: false, dataIndex: 'FAMILYBRANDCODE', filter: {}},
{header: "#JSStringFormat(lang_rb.familyBrand)#", width: 175, sortable: true, hidden: false, dataIndex: 'FAMILYBRANDDESC', filter: {}},
{header: "#JSStringFormat(lang_rb.licensorCode)#", width: 50, sortable: true, hidden: false, dataIndex: 'LICENSORCODE', filter: {}},
{header: "#JSStringFormat(lang_rb.licensor)#", width: 175, sortable: true, hidden: false, dataIndex: 'LICENSORDESC', filter: {}},
{header: "#JSStringFormat(lang_rb.propertyCode)#", width: 50, sortable: true, hidden: false, dataIndex: 'PROPERTYCODE', filter: {}},
{header: "#JSStringFormat(lang_rb.property)#", width: 175, sortable: true, hidden: false, dataIndex: 'PROPERTYDESC', filter: {}}
]);
var myCFReader = new Ext.data.JsonReader({
idProperty: 'MATERIAL',
root: 'ROWS',
successProperty:'SUCCESS', // CF returns Json variable names in uppercase
messageProperty: 'MESSAGE',
totalProperty: 'RECORDCOUNT',
// the fields config option will internally create an Ext.data.Record
// constructor that provides mapping for reading the record data objects
fields: [
{name: 'MATERIAL', type:'string'},
{name: 'MATERIALDESCRIPTION', type:'string'},
{name: 'EANCODE', type:'string'},
{name: 'SKU', type:'string'},
{name: 'UNITSPERCARTON', type:'int'},
{name: 'UNITPRICE', type:'float'},
{name: 'PRODUCTCLASSIFICATIONCODE', type:'string'},
{name: 'PRODUCTCLASSIFICATIONDESC', type:'string'},
{name: 'SUPERCATEGORYCODE', type:'string'},
{name: 'SUPERCATEGORYDESC', type:'string'},
{name: 'CATEGORYCODE', type:'string'},
{name: 'CATEGORYDESC', type:'string'},
{name: 'INTERNALCLASSIFICATIONCODE', type:'string'},
{name: 'INTERNALCLASSIFICATIONDESC', type:'string'},
{name: 'BRANDCODE', type:'string'},
{name: 'BRANDDESC', type:'string'},
{name: 'FAMILYBRANDCODE', type:'string'},
{name: 'FAMILYBRANDDESC', type:'string'},
{name: 'LICENSORCODE', type:'string'},
{name: 'LICENSORDESC', type:'string'},
{name: 'PROPERTYCODE', type:'string'},
{name: 'PROPERTYDESC', type:'string'} ]
});
//The Proxy object will specify URLs to call for different CRUD operations
var proxy = new Ext.data.HttpProxy({
method:'POST',
api:{
read: 'remote/stsRemote.cfc?method=readMaterialMasterJson'
}
});
...
抱歉,如果格式化了
答案 0 :(得分:0)
这是因为JavaScript将98694E130
解释为98694*10^130
。这被称为“科学记数法”。为了避免这种情况,请确保您的值是一个字符串,并且永远不会被非自愿地转换为整数(或任何数字类型)
从您的评论中看来,在您从服务器返回的JSON中,98694E130
列的MATERIAL
值未被引用,因此JavaScript会将其解释为数字。
答案 1 :(得分:0)
如果你的函数的returnType是'struct'而你在函数上使用'returnFormat = JSON'属性,你可能想尝试这个:
将您的返回类型更改为“string”,将returnFormat更改为“plain”,然后将cfreturn更改为SerializeJSON(struckObj)
我发现这有时会解决这样的问题。