Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从JSON加载ExtJS树存储_Extjs_Salesforce_Visualforce_Treepanel - Fatal编程技术网

从JSON加载ExtJS树存储

从JSON加载ExtJS树存储,extjs,salesforce,visualforce,treepanel,Extjs,Salesforce,Visualforce,Treepanel,我已经为此绞尽脑汁12个小时了,什么也没得到。我非常感谢你的帮助或指导。我无法获得visualforce页面来呈现带有JSON数据的sensa extjs树面板。我使用的是ExtJS4.2.1 我有一个salesforce apex类,它生成一个JSON字符串,如下所示: {"children": [{"StartDate":null, "Location":"<a href=\"null\">null</a>", "leaf":false, "isSelected":n

我已经为此绞尽脑汁12个小时了,什么也没得到。我非常感谢你的帮助或指导。我无法获得visualforce页面来呈现带有JSON数据的sensa extjs树面板。我使用的是ExtJS4.2.1

我有一个salesforce apex类,它生成一个JSON字符串,如下所示:

{"children":
[{"StartDate":null,
"Location":"<a href=\"null\">null</a>",
"leaf":false,
"isSelected":null,
"isActive":null,
"id":"rootnodeid",
"children":[{
                "StartDate":"2007-01-26","ShiftStartTime":"",
                "Location":"<a href=\"null\">null</a>",
                "leaf":true,"isSelected":null,
                "isSelected":null,
                "isActive":true,
                "id":"701i0000000a2OZAAY",
                "children":null}
            }]
}], 
"success": true }
{“子项”:
[{“StartDate”:空,
“地点”:“,
“叶子”:假,
“isSelected”:空,
“isActive”:空,
“id”:“rootnodeid”,
“儿童”:[{
“开始日期”:“2007-01-26”,“班次开始时间”:”,
“地点”:“,
“叶”:true,“isSelected”:null,
“isSelected”:空,
“isActive”:是的,
“id”:“701i0000000a2OZAAY”,
“子项”:null}
}]
}], 
“成功”:真的}
(注意,我删除了一些字段和记录,如果有帮助的话,我可以发布整个内容)

我有一个visualforce页面来呈现数据,但我只能让它显示列,而不能显示其他内容。下面是我的视觉力量页面

<!-- Visualforce (using ExtJS) display/selection of Campaign hierarchy two ways by Jeff Trull (linmodemstudent@gmail.com) -->
<apex:page controller="VolunteerShiftControllerNew" tabstyle="Campaign">                                                    
<!-- get the ExtJS stuff from the static resource I uploaded -->                                                        
<apex:stylesheet value="{!$Resource.ExtJS}/extjs-4.2.1/resources/ext-theme-gray/ext-theme-gray-all.css" />                                     
<apex:includeScript value="{!$Resource.ExtJS}/extjs-4.2.1/ext-all-debug-w-comments.js"/>   



<script type="text/javascript">
    Ext.onReady(function(){

    Ext.define('CampaignModel', {
            extend: 'Ext.data.TreeStore',
            autoLoad: true,
            defaultRootProperty: "children",
            fields: [
                {name: 'name',     type: 'string'},
                {name: 'parentId',     type: 'string'},
                {name: 'StartDate',     type: 'date'},
                {name: 'isActive',     type: 'boolean'},
                {name: 'Location',     type: 'string'},
                {name: 'ShiftStartTime',     type: 'string'},
                {name: 'ShiftEndTime',     type: 'string'},
                {name: 'numVolunteersNeeded',     type: 'integer'},
                {name: 'numOpenSpots',     type: 'integer'}

            ]
    });

    var mytreestore = Ext.create('CampaignModel', {
            model: 'CampaignModel',
            proxy: {
                        type    : 'memory',
                        reader  : {
                            type : 'json',
                            root: 'children'
                        }
                   }


    });        

    var mytree = Ext.create('Ext.tree.Panel',{
        alias: 'widget.tivcpanel',
        renderTo: treediv,
        useArrows: true,
        autoScroll: true,
        animate: true,
        containerScroll: true,
        border: false,
        store: mytreestore,
        columns: [{
            xtype: 'treecolumn', //this is so we know which column will show the tree
            text: 'Name',
            flex: 2,
            sortable: true,
            dataIndex: 'name'
        },
            {text: 'Location',
            flex:1,
            dataIndex: 'Location',
            sortable: true
            },
            {text: 'Start Date',
            flex:1,
            dataIndex: 'StartDate',
            sortable: true,
            xtype:'datecolumn'
            },
            {text: 'Start Time',
            flex:1,
            dataIndex: 'ShiftStartTime',
            sortable: true
            },                    
            {text: 'End Time',
            flex:1,
            dataIndex: 'ShiftEndTime',
            sortable: true
            },                    
             {text: '# Open Spots',
            flex:1,
            dataIndex: 'numOpenSpots',
            sortable: true,
            xtype: 'numbercolumn',
            format: '0',
            renderer: function(value) {
                 if(value===-1) return '';
                 else return value;
            } 

            },                   
             {text: 'Is Active',
            flex:1,
            dataIndex: 'isActive',
            sortable: true
            //xtype: 'mytreecheckcolumn'

            }                    
         ]               
    });        

    TIVC.VolunteerShiftControllerNew.getMatchingShifts(function(result, er){ //This method is used to call our controller method
                                var res = Ext.decode(result);
                                debugger;
                                mytreestore.load(res.Records);
                                debugger;
                            }, {escape:false});          


   }); 


</script>
<apex:form id="hiddenInputForm">
</apex:form>

<apex:pageBlock title="Selecting Campaigns via TreePanel">
    <div id="treediv"/>
</apex:pageBlock>

Ext.onReady(函数(){
Ext.define(‘活动模型’{
扩展:“Ext.data.TreeStore”,
自动加载:对,
defaultRootProperty:“子项”,
字段:[
{name:'name',type:'string'},
{name:'parentId',type:'string'},
{name:'StartDate',键入:'date'},
{name:'isActive',type:'boolean'},
{name:'Location',type:'string'},
{name:'ShiftStartTime',键入:'string'},
{name:'ShiftEndTime',键入:'string'},
{name:'numvolunterseeded',键入:'integer'},
{name:'numpenspots',键入:'integer'}
]
});
var mytreestore=Ext.create('活动模型'{
模型:“活动模型”,
代理:{
键入:“内存”,
读者:{
键入:“json”,
根:“儿童”
}
}
});        
var mytree=Ext.create('Ext.tree.Panel'{
别名:“widget.tivcpanel”,
renderTo:treediv,
是的,
autoScroll:是的,
动画:对,
集装箱克罗尔:是的,
边界:错,
商店:mytreestore,
栏目:[{
xtype:'treecocolumn',//这样我们就知道哪一列将显示该树
文本:“名称”,
弹性:2,
可排序:是的,
数据索引:“名称”
},
{文本:'位置',
弹性:1,
dataIndex:'位置',
可排序:正确
},
{文本:“开始日期”,
弹性:1,
数据索引:“开始日期”,
可排序:是的,
xtype:'datecolumn'
},
{文本:“开始时间”,
弹性:1,
dataIndex:'ShiftStartTime',
可排序:正确
},                    
{文本:'结束时间',
弹性:1,
dataIndex:'ShiftEndTime',
可排序:正确
},                    
{文本:'#开放点',
弹性:1,
dataIndex:'numOpenSpots',
可排序:是的,
xtype:'numbercolumn',
格式:“0”,
渲染器:函数(值){
如果(值==-1)返回“”;
否则返回值;
} 
},                   
{文本:'处于活动状态',
弹性:1,
数据索引:“isActive”,
可排序:正确
//X类型:“mytreecheckcolumn”
}                    
]               
});        
getMatchingshift(函数(result,er){//此方法用于调用我们的控制器方法
var res=外部解码(结果);
调试器;
mytreestore.load(res.Records);
调试器;
},{escape:false});
}); 

我真的不知道我在用Javascript做什么,我肯定我错过了一些愚蠢的东西。我知道数据正在进入visualforce页面,就我所知,通过chrome javascript调试工具,它至少会进入我的结果变量(res),但不会呈现任何内容


请帮忙!我保证我已经在谷歌上做了尽职调查:)。

A1rPun为我指明了正确的方向。首先,当调用树存储的load方法并将解码json结果的“Records”变量传递给它时,我很愚蠢。我的结果没有这个变量,所以这显然对我没有任何帮助

相反,我最终使用了以下命令(关键是传入results对象,而不是子对象数组,因为它看起来像是treestore为我做的

            TIVC.VolunteerShiftControllerNew.getMatchingShifts(function(result, er){ //This method is used to call our controller method
                                    var res = Ext.decode(result);
                                    mytreestore.setRootNode(res);
                                    debugger;
                                }, {escape:false}); 

您是否尝试过
mytreestore.setRootNode(res.Records);
而不是
mytreestore.load(res.Records);
?我现在尝试过,但它没有改变任何东西。我很确定数据已加载到树中,但实际更新div的顺序不正确?