对于想了解javascript–从jsonstoreextjs获取记录的读者,本文将提供新的信息,我们将详细介绍js如何获取json内的数据,并且为您提供关于Extjs显示从数据库取出时间转换JSON
对于想了解javascript – 从json store extjs获取记录的读者,本文将提供新的信息,我们将详细介绍js如何获取json内的数据,并且为您提供关于Extjs显示从数据库取出时间转换JSON后的出现问题_javascript技巧、javascript Ext JS 状态默认存储时间_extjs、javascript – ExtJS4 LinkButton组件、javascript – Extjs多重继承?的有价值信息。
本文目录一览:- javascript – 从json store extjs获取记录(js如何获取json内的数据)
- Extjs显示从数据库取出时间转换JSON后的出现问题_javascript技巧
- javascript Ext JS 状态默认存储时间_extjs
- javascript – ExtJS4 LinkButton组件
- javascript – Extjs多重继承?
javascript – 从json store extjs获取记录(js如何获取json内的数据)
我有一个json存储加载,我需要从中获取一条记录.
我用过:getAt(index),find(),getById(),但没有结果.
这是我的代码:
var appSettingReader = new Ext.data.JsonReader({
root: ''results'',
},[
{name: ''id'', type: ''int'', mapping: ''id''},
{name: ''projetId'', type: ''int'', mapping: ''projetId''},
{name: ''resLevels'', type: ''int'', mapping: ''resLevels''},
{name: ''maxResToLock'', type: ''int'', mapping: ''maxResToLock''},
{name: ''maxTimetoLock'', type: ''int'', mapping: ''maxTimetoLock''},
{name: ''infosToPrint'', type: ''string'', mapping: ''infosToPrint''}
])
var appSettingStore = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: ''inc/getSettings.PHP'',
method: ''POST''
}),
baseParams:{task: "app"},
reader : appSettingReader,
sortInfo:{field: ''id'', direction: "DESC"}
})
appSettingStore.load();
此代码返回undefined:
console.log(appSettingStore.getAt(0));
console.log(appSettingStore.find("id","1"));
这是从服务器返回的json字符串:
{success:true,"results":[{"id":"1","projetId":"1","resLevels":"1","maxResToLock":"40","maxTimetoLock":"10","infosToPrint":"1_2_3_5","hotlineMail":"admin@app.com"}]}
我也测试了这段代码:
var records = new Array()
var test = appSettingStore.each(function(rec){
records.push(rec)
})
console.log(records)
我得到一个空数组!
PS:这个商店不受任何组件的约束;
我只想读写它.
解决方法:
您需要在商店上放置一个回调,它将在加载后触发.然后,您可以根据需要使用数据.
store.load({
callback : function(r, options, success) {
console.log(r.data)
}
})
总结
以上是小编为你收集整理的javascript – 从json store extjs获取记录全部内容。
如果觉得小编网站内容还不错,欢迎将小编网站推荐给好友。
原文地址:https://codeday.me/bug/20190726/1545030.html
Extjs显示从数据库取出时间转换JSON后的出现问题_javascript技巧
后台从数据库取出时间,JSON格式化后再传到gridpanel,这时时间变成了:/Date(32331121223)/这样的格式,那么这时需要以下处理才可以正常显示:
在
var record = Ext.data.Record.create([
{ name: ''PublicDate'', mapping: ''PublicDate'', dateFormat: ''Y-m-d'', convert: function (v) {
if (v == null) {
return null;
}
var d = new Date();
var str = v.toString();
var str1 = str.replace("/Date(", "");
var str2 = str1.replace(")/", "");
var dd = parseInt(str2);
d.setTime(dd);
return d;
} }
]);
然后在:
var cm = new Ext.grid.ColumnModel([
{ header: ''发布时间'', dataIndex: ''PublicDate'', width: 120, align: ''center'', renderer: Ext.util.Format.dateRenderer(''Y-m-d'') }
]);