我需要声明一个变量TeacherName,它将从DataStore字段'NameT'接收其值
var storeTeacher = new Ext.data.JsonStore({
id: 'IDstoreTeacher',
url: 'teacher.php',
method: 'POST',
baseParams:{task: "TEACHERNAME",
parametar: idTeacher},
root: 'rows',
fields: [{name: 'NameT', type: 'string', mapping: 'teacher_name'}],
autoLoad: true
});
var TeacherName = NameT;
但是在Firebug中我总是收到以下错误消息: “未捕获的ReferenceError:未定义NameT”
答案 0 :(得分:1)
您需要从商店获取nameT,如下所示:
如果您想要第一行中的名称:
var TeacherName = storeTeacher.getAt(0).get('NameT');
如果您收到存储为null或其他内容的错误,请使用函数load中的代码:
storeTeacher.load({
scope: this,
callback: function (records, operation, success) {
var TeacherName = storeTeacher.getAt(0).get('NameT');
}
});