Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.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
Kendo ui 剑道UI:绑定实践_Kendo Ui - Fatal编程技术网

Kendo ui 剑道UI:绑定实践

Kendo ui 剑道UI:绑定实践,kendo-ui,Kendo Ui,我不确定我的场景的最佳方式是什么,所以我将首先解释这一点 我有两个数据源。人员和组,每个人员项目都有一个指示器,指示它所属的组。将人员绑定到剑道网格,将组绑定到。我的问题是,我想在组之外显示一个计数,它指示该组中有多少人-此信息是从persons数据源计算的,而不是组本身的一部分 对不起,这个一般性的问题-但我真的很难回答这个问题 更新:以下是我现在拥有的: var contactGroupsDataSource = new kendo.data.DataSource({ transport

我不确定我的场景的最佳方式是什么,所以我将首先解释这一点

我有两个数据源。人员和组,每个人员项目都有一个指示器,指示它所属的组。将人员绑定到剑道网格,将组绑定到
    。我的问题是,我想在组之外显示一个计数,它指示该组中有多少人-此信息是从persons数据源计算的,而不是组本身的一部分

    对不起,这个一般性的问题-但我真的很难回答这个问题

    更新:以下是我现在拥有的:

    var contactGroupsDataSource = new kendo.data.DataSource({
      transport: {
        read: {
          url: "api/contactgroups"
        }
      }
    });
    
    $('#contactGroupsList').kendoListView({
        dataSource: contactGroupsDataSource,
        template: "<li class='contactGroupListItem' data-number='${Number}'>${Number} ${Name} (<span data-bind="text: cgcount[1]"></span>) </li>"
    });
    
    viewModel = kendo.observable({
            contactsDataSource: new kendo.data.DataSource({
                transport: {
                    read: {
                        url: "api/contacts"
                    }
                },
                schema: {
                    model: {
                        id: "Id",
                        fields: {
                            id: { type: "string" },
                            FirstName: { type: "string" },
                            LastName: { type: "string" },
                            ContactGroupNumber: { type: "integer" }
                        }
                    }
                },
                change: function (e) {
                    var data = this.data();
    
                    for (var i = 0; i < data.length; i++) {
                        var cg = data[i]["ContactGroupNumber"];
                        viewModel.cgcount.splice([cg - 1], 1, viewModel.cgcount[cg - 1] + 1);
                    }
    
                    for (var i = 0; i < 7; i++) {
                        console.log(i + 1 + ': ' + viewModel.cgcount[i]);
                    }
                }
            }),
            cgcount: new kendo.data.ObservableArray([0, 0, 0, 0, 0, 0, 0])
        });
    
        kendo.bind($("#contactsGroupContainer"), viewModel);
    
        contactsListView = $('#contactsList').kendoGrid({
            dataSource: viewModel.contactsDataSource,
            sortable: true,
            rowTemplate: kendo.template($("#rowTemplate").html())
        });
    
    var contactGroupsDataSource=new kendo.data.DataSource({
    运输:{
    阅读:{
    url:“api/contactgroups”
    }
    }
    });
    $(“#contactGroupsList”).kendoListView({
    数据源:contactGroupsDataSource,
    模板:“
  • ${number}${Name}()
  • ” }); viewModel=kendo.observable({ contactsDataSource:新建kendo.data.DataSource({ 运输:{ 阅读:{ url:“api/联系人” } }, 模式:{ 型号:{ id:“id”, 字段:{ id:{type:“string”}, 名字:{type:“string”}, 姓氏:{type:“string”}, ContactGroupNumber:{type:“integer”} } } }, 更改:功能(e){ var data=this.data(); 对于(变量i=0;i

    丹尼尔

    你能提供你现在拥有的代码吗?我用当前代码编辑了我的文章。我尝试了几种不同的方法,但我认为这一种显示了我想要实现的目标。