Kendo UI Hierarchy儿童计划 [英] Kendo UI Hierarchy children scheme

查看:104
本文介绍了Kendo UI Hierarchy儿童计划的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!



关于剑道的API参考(证明:Kendo UI API参考 - Schema.Model.Children ),子节点可以在下一个方法中声明(参见嵌套'schema'作为'定义第二级的选项'):



  var  datasource = < span class =code-keyword> new  kendo.data.HierarchicalDataSource({
data:[
{
categoryName: SciFi
部电影:[
{title: 星球大战:新希望,年: 1977 ,演员:[
{actor: Mark Hamill,字符: Luke Skywalker},
{actor: Harrison Ford,字符: Han Solo},
{actor: Carrie Fisher,字符: Princess Leia Organa}
]},
{title: 星球大战:帝国反击战,年: 1980 ,演员:[
{actor: Mark Hamill,character: Luke Skywalker},
{actor: 哈里森福特,字符: Han Solo},
{actor: Carrie Fisher,字符: 莱娅公主Organa},
{actor: Billy Dee Williams,字符: Lando Calrissian}
]}
]
}
],
架构:{
型号:{
children:{ // 定义第二级的选项
架构:{
data: 电影
型号:{
children: cast // 第三级由字段cast定义
}
}
}
}
}
}) ;





我对HierarchicalDataSource使用类似的定义并以这种方式获取子节点:



架构:{
型号:{
id: urb_fltr
hasChildren: true
children: PhoneCalls // < - 这里是子项的定义是 - 来自输出字段的数据(下一个在解析中)
},
parse: function (data) {
var outRes = [];
var dataRes = [];
var tmpLoop = 0 ;
var bordNum = 251170009 ;

if (data.d.results!= null && data.d.results.length> 0
for var step = 0 ; step< data.d.results.length; step ++){

if (data.d.results [step] == null 继续;

var stepData = data.d.results [step];

var stepValue =(stepData.urb_subject!= null )? stepData.urb_subject.Value: 0 ;

var arrValue =(stepValue> bordNum)? stepValue - bordNum: 0 ;

if (outRes [arrValue] == null || typeof (outRes [arrValue])== ' undefined'){
outRes [arrValue] = {};
outRes [arrValue] .urb_total = 1 ;
outRes [arrValue] .urb_clnts = 0 ;

outRes [arrValue] .OwnerId = stepData.OwnerId;
outRes [arrValue] .urb_subjectValue = stepValue;

outRes [arrValue] .PhoneCalls = []; // < - children
}
else
outRes [arrValue] .urb_total + = 1 ;
// 填充子字段
outRes [arrValue] .PhoneCalls [outRes [ arrValue] .urb_total - 1 ] = {};
outRes [arrValue] .PhoneCalls [outRes [arrValue] .urb_total - 1 ]。CallId = stepData.ActivityId;
outRes [arrValue] .PhoneCalls [outRes [arrValue] .urb_total - 1 ]。urb_name = stepData.urb_name;
outRes [arrValue] .PhoneCalls [outRes [arrValue] .urb_total - 1 ]。CreatedOn = stepData.CreatedOn;
outRes [arrValue] .PhoneCalls [outRes [arrValue] .urb_total - 1 ]。PhoneNumber = stepData.PhoneNumber;
outRes [arrValue] .PhoneCalls [outRes [arrValue] .urb_total - 1 ]。ScheduledEnd = stepData.ScheduledEnd;

if (stepData.RegardingObjectId!= null && stepData。 AboutObjectId.Id!= null && stepData.RegardingObjectId.LogicalName == lead){
outRes [arrValue] .PhoneCalls [outRes [arrValue] .urb_total - 1 ]。AboutObjectId = stepData.RegardingObjectId;
outRes [arrValue] .urb_clnts + = 1 ;
}
}

for var 循环= 0 ; loop< outRes.length; loop ++)
if typeof (outRes [loop])!= ' undefined' ){
outRes [loop] .urb_subjectName = outRes [loop] .urb_subjectName + + outRes [loop] .urb_total + - + outRes [loop] .urb_clnts + ;
dataRes [tmpLoop] = outRes [loop];
tmpLoop ++;
}

return dataRes; // data.d.results;
},
类型: json
}





没关系,我可以通过这种方式看到孩子们。但默认情况下,'hasChildren'的属性为'true',我为API参考中的子项制定了计划:



 children: { //  <  - 而不是PhoneCalls 
架构:{
data: PhoneCalls
model:{
hasChildren: false
}
}
}





并且完全失去了孩子。



任何人都可以帮助正确定义方案中的子属性吗?

解决方案

解决方案:

1.忘记'children'中的'schema'括号 - 转回PhoneCalls字符串值。

2.在''添加'hasChildren'属性' PhoneCall'对象(来自PhoneCalls设置)并将值设置为'false'。



如果你想添加ne w树级视图:

1.将PhoneCall对象的'hasChildren'属性设置为'true'

2.将从属集添加为PhoneCall的属性对象

3.在PhoneCall对象中添加'children'属性,该对象将是一个字符串值 - 来自p的set属性的名称。 2

Hi all!

Regarding to a API reference for Kendo (proof: Kendo UI API Reference - Schema.Model.Children), children nodes can be declare in next approach (see nested 'schema' as 'define options for second level'):

var datasource = new kendo.data.HierarchicalDataSource({
  data: [
    {
      categoryName: "SciFi",
      movies: [
        { title: "Star Wars: A New Hope", year: 1977, cast: [
            { actor: "Mark Hamill", character: "Luke Skywalker" },
            { actor: "Harrison Ford", character: "Han Solo" },
            { actor: "Carrie Fisher", character: "Princess Leia Organa" }
        ] },
        { title: "Star Wars: The Empire Strikes Back", year: 1980, cast: [
            { actor: "Mark Hamill", character: "Luke Skywalker" },
            { actor: "Harrison Ford", character: "Han Solo" },
            { actor: "Carrie Fisher", character: "Princess Leia Organa" },
            { actor: "Billy Dee Williams", character: "Lando Calrissian" }
        ] }
      ]
    }
  ],
  schema: {
    model: {
      children: { // define options for second level
        schema: {
          data: "movies",
          model: {
            children: "cast" // third level is defined by the field "cast"
          }
        }
      }
    }
  }
});



I use similar definition for HierarchicalDataSource and get children nodes in that way:

schema: {
  model: {
    id: "urb_fltr",
    hasChildren: true,
    children: "PhoneCalls" // <- here is definition for children that are - data from field of output (next in parse)
  },
  parse: function (data) {
    var outRes = [];
    var dataRes = [];
    var tmpLoop = 0;
    var bordNum = 251170009;

    if (data.d.results != null && data.d.results.length > 0)
      for (var step = 0; step < data.d.results.length; step++) {

        if (data.d.results[step] == null) continue;

        var stepData = data.d.results[step];

        var stepValue = (stepData.urb_subject != null) ? stepData.urb_subject.Value : 0;

        var arrValue = (stepValue > bordNum) ? stepValue - bordNum : 0;

        if (outRes[arrValue] == null || typeof (outRes[arrValue]) == 'undefined') {
          outRes[arrValue] = {};
          outRes[arrValue].urb_total = 1;
          outRes[arrValue].urb_clnts = 0;

          outRes[arrValue].OwnerId = stepData.OwnerId;
          outRes[arrValue].urb_subjectValue = stepValue;

          outRes[arrValue].PhoneCalls = []; // <- children
        }
        else
          outRes[arrValue].urb_total += 1;
                                    // fill children field
                                outRes[arrValue].PhoneCalls[outRes[arrValue].urb_total - 1] = {};
                                outRes[arrValue].PhoneCalls[outRes[arrValue].urb_total - 1].CallId = stepData.ActivityId;
                                outRes[arrValue].PhoneCalls[outRes[arrValue].urb_total - 1].urb_name = stepData.urb_name;
                                outRes[arrValue].PhoneCalls[outRes[arrValue].urb_total - 1].CreatedOn = stepData.CreatedOn;
                                outRes[arrValue].PhoneCalls[outRes[arrValue].urb_total - 1].PhoneNumber = stepData.PhoneNumber;
                                outRes[arrValue].PhoneCalls[outRes[arrValue].urb_total - 1].ScheduledEnd = stepData.ScheduledEnd;

                                if (stepData.RegardingObjectId != null && stepData.RegardingObjectId.Id != null && stepData.RegardingObjectId.LogicalName == "lead") {
                                    outRes[arrValue].PhoneCalls[outRes[arrValue].urb_total - 1].RegardingObjectId = stepData.RegardingObjectId;
                                    outRes[arrValue].urb_clnts += 1;
                }
            }

        for (var loop = 0; loop < outRes.length; loop++)
            if (typeof (outRes[loop]) != 'undefined') {
                outRes[loop].urb_subjectName = outRes[loop].urb_subjectName + " ( " + outRes[loop].urb_total + " - " + outRes[loop].urb_clnts + " )";
                dataRes[tmpLoop] = outRes[loop];
                tmpLoop++;
            }

        return dataRes; //data.d.results;
    },
    type: "json"
}



It's OKay and I can see children in that way. But by default, property of 'hasChildren' is 'true' and I make scheme for children like in API reference:

children: { // <- instead of "PhoneCalls"
  schema: {
    data: "PhoneCalls",
      model: {
        hasChildren: false
        }
     }
  }



, and quite lose children.

Can anyone help define children property with scheme correctly?

解决方案

Solution:
1. Forget about 'schema' brace in 'children' - turn back the "PhoneCalls" string value.
2. Add the 'hasChildren' property in the 'PhoneCall' object (from "PhoneCalls" set) and set the value in 'false'.

If you want to add new level of treeview:
1. Set the 'hasChildren' property of "PhoneCall" objects in 'true'
2. Add the subordinated set as attribute of "PhoneCall" objects
3. Add the 'children' property in "PhoneCall" objects that would be a string value - name of set attribute from p. 2


这篇关于Kendo UI Hierarchy儿童计划的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆