• ExtJS4.0 JSON数据无法显示的问题


    Ext.regModel('EncyModel', { fields: ['ENCY_ID', 'UP_ENCY_ID', 'ENCY_NAME', 'ENCY_PAGE_ID', 'ENCY_SEQ'] });

    var store = Ext.create('Ext.data.TreeStore', {
    proxy: {
    type: 'ajax',
    url: '/Scripts/check-nodes2.json',
    reader: {
    type: 'json'
    },
    },
    model:'EncyModel',
    //nodeParam: 'ENCY_ID',
    root: {
    text: '百科',
    id: '-1',
    }
    var tree = Ext.create('Ext.tree.Panel',

    {
    renderTo: "main",
    store: store,
    rootVisible: true,
    useArrows: true,
    title: "词条组管理",
    height: 400,
    980,
    frame: true,
    bodyPadding: 5,
    columns: [{
    xtype: 'treecolumn',
    text:'百科',
    dataIndex: 'ENCY_NAME',
    150,
    sortable:true
    },
    {
    text:'详细',
    dataIndex: 'ENCY_ID',
    150,
    sortable:true
    }
    ]

    1.JSON格式返回有问题

    2.Ext.data.TreeStore 中root 必须要写 

    root: {

    text: '百科', // text 字段是跟 model 中的名称 在这个里面应该是 ENCY_NAME=‘百科’
    ENCY_ID: '-1',
    }

    3.显示出来 数据没有显示名称,只有文件夹 没有文件夹名称,发现把 dataIndex: 'text' 设置为text 更改JSON 返回文件把名称修改为‘text’ 相对应就可以了

    那我还要是想显示别的字段呢,我的JSON 里有好多个字段。经过研究 要指定 model ,不指定model就要写在Ext.data.TreeStore中增加 fields:['name','text','ENCY_ID'],  显示这么多字段,EXT就可以自动匹配了,不然在Treepanel 里dataIndex 就只能识别默认的text 字段。

    4.返回数据中要用children 作为集合的名称,要用 leaf 字段显示是否是 叶子,

  • 相关阅读:
    Javascript实现局部刷新
    Javascript模块化开发-轻巧自制
    javascript面向对象实例
    Javascript兼容和CSS兼容总结
    隐藏关机按钮
    数组排序
    常用数组获取最新和第一个元素值
    php 操作redis 以及几个常用命令
    git 常用命令
    JSON.parse和JSON.stringify的区别
  • 原文地址:https://www.cnblogs.com/90nice/p/3106048.html
Copyright © 2020-2023  润新知