gpt4 book ai didi

javascript - 在 extjs 中渲染表单 html 标签中的对象

转载 作者:行者123 更新时间:2023-11-28 07:14:36 24 4
gpt4 key购买 nike

我使用的是 extjs 3.4。我有一个表格。里面我想显示一些ajax内容。但每当提醒该变量时,我都会得到 [object object]。我尝试了 stringify Json.decode 但没有运气。这是我的代码,

var sourcePath = new Ext.data.Store({
reader: new Ext.data.JsonReader({
fields: ['path'],
root: 'rows'
}),
proxy: new Ext.data.HttpProxy({
url: '/plugin/BODImageImport/admin/getsourcepath'
}),
autoLoad: true
});

还有我的表格,

var bodimportForm = new Ext.form.FormPanel({
html: "<p>Imgae source: <b>"+ sourcePath +"</b> folder in root directory</p>",
url: '/plugin/BODImageImport/admin/import',

任何帮助或提示都会对我很有帮助。

更新:

我的 Json 看起来像这样,

{"rows":[{"path":"bodyshop\/tr\/media\/inbox"}]}

我只是想在 html 标记中获取该路径。

更新:当我使用 console.log() 打印对象时,我得到了以下内容。但我不知道如何获得我的值(value), Console

最佳答案

这里的sourcePath是一个商店实例。

所以你不能做html:

Imgae来源:“+ sourcePath +”

为了获得商店内的值(value),您必须这样做

//index you are interested
m = sourcePath.getAt( index ) //this will give the model m
//m.path to get the path

在你的阅读器内

reader: new Ext.data.JsonReader({
fields: ['path'],
root: 'rowsDir'
}),

应该是

reader: new Ext.data.JsonReader({
fields: ['path'],
root: 'rows'
}),

因为你的 json 根是 rows 而不是 rowsDir

关于javascript - 在 extjs 中渲染表单 html 标签中的对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30972365/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com