[英]Grief with extJS4 treegrid using custom model and async loading
我只是似乎無法啟動樹狀網格並運行它。 我已經定義了模型,商店和treegrid(如下所示)。 樹形網格顯示目標內部,數據已異步加載(通過提琴手檢查,返回了兩行),但是樹形網格僅顯示了兩行帶有空單元格。
我嘗試調試,並且商店的根節點確實有兩個子節點,模型數據在子節點的raw
屬性下(某些字段(如也在data
屬性中的leaf和iconCls除外)),但是樹形網格顯示了兩個空行,盡管dataIndex指向適當的模型字段。
就像樹網格找不到模型定義的字段一樣!!?
這是源(我使用沙箱是因為將其集成到salesforce vforce中,salesforce合並字段{!}也是有效的並且可以正確呈現)
Ext4.onReady(function() {
var target = '{!$Component.childBlock.childTreeDiv}';
Ext4.define('ConfigurationItem', {
extend: 'Ext4.data.Model',
fields: [
{
id: 'id',
type: 'string'},
{
id: 'name',
type: 'string'},
{
id: 'recordType',
type: 'string'},
{
id: 'ciName',
type: 'string'},
{
id: 'alias',
type: 'string'},
{
id: 'model',
type: 'string'},
{
id: 'status',
type: 'string'},
{
id: 'description',
type: 'string'},
{
id: 'leaf',
type: 'bool'},
{
id: 'iconCls',
type: 'string'}
]
});
var store = Ext4.create('Ext4.data.TreeStore', {
model: 'ConfigurationItem',
root: {
nodetype: 'async',
id: '{!CI__c.Id}',
expanded: true
},
proxy: {
type: 'ajax',
url: 'json_CIChildren',
reader: {
type: 'json',
root: 'children'
}
}
});
tree = Ext4.create('Ext4.tree.Panel', {
width: document.getElementById(target).offsetWidth,
autoHeight: true,
title: 'Child Configuration Items',
collapsible: true,
titleCollapse: true,
renderTo: target,
rootVisible: false,
store: store,
multiSelect: true,
singleExpand: true,
columns: [
{
type: 'treecolumn',
text: 'CI#',
dataIndex: 'name'},
{
text: 'Type',
dataIndex: 'recordType'}
]
});
});
對json_CIChildren?_dc=1329830854458&node=a0NT0000006tYKzMAM
的請求有效( json_CIChildren?_dc=1329830854458&node=a0NT0000006tYKzMAM
中的parentID
root.id
傳播),並返回有效的json:
{ "children" : [
{
"id": "a0NT0000006tswhMAA",
"name": "CI334593834",
"recordType": "Rack",
"ciName": "Empty rack",
"alias": "",
"model": "",
"status": "",
"description": "",
"leaf": "true",
"iconCls": "x4-ciicon-Rack"
},
{
"id": "a0NT0000006tYKuMAM",
"name": "CI2345234",
"recordType": "Service",
"ciName": "Business Connect - Premium",
"alias": "",
"model": "",
"status": "",
"description": "",
"leaf": "true",
"iconCls": "x4-ciicon-Service"
}
]}
我究竟做錯了什么? 為什么treegrid看不到name和recordType字段?
這是因為存儲只看到了類似NodeInterface的字段,並且data屬性中沒有我的自定義數據嗎?
我認為問題在於您的模型字段映射不正確。 每個字段的“ id”屬性應改為“ name”屬性。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.