带有角的kendo ui listview-可选项目

我有一个kendo ui ListView,我想使这些项目为可选择的(单选)。我没有在网上找到任何带有角度的样品。

我要做的是为所选项目设置样式,并根据所选项目进行一些调用。

这是我的HTML

            <div class="list-group no-radius no-border no-bg m-b-none"
                 kendo-list-view="publishPositionsListView"
                 k-options="ctrl.publishPositionsSourceOptions"
                 k-data-source="ctrl.publishPositionsSource">

                <a class="list-group-item p-l hover-anchor b-a no-select ng-scope" k-template>
                    <span>{{dataItem.Title}}</span>
                </a>
            </div>

这是我的JavaScript

vm.publishPositionsSource = new kendo.data.DataSource({
    dataType: "aspnetmvc-ajax",
    transport: {
        read: {
            url: "publish/getall",
            type: "GET"
        }
    },
    schema: {
        type: "json",
        data: "Data",
        total: "Total",
        model: {
            id: "Id"
        }
    }
});

vm.publishPositionsSourceOptions = {
    dataBound: function (e) {
        // Set selected style for the first item when loaded
        e.sender.element.children().first().addClass("focus");
    }
}

任何想法?我想知道是否有一种方法可以代替使用ng-click

菲利普

要在kendoUI列表视图上启用单选,请添加selectable: "Single"到您的listview-config。您还可以使用列表视图的select方法以编程方式设置所选项目

当您将它们放在一起时,可能看起来像这样:

$scope.listViewOptions = {
    dataSource: $scope.myDataSource,
    selectable: "Single",
    dataBound: function(event) {
        /* Select the first item here */
    },
    change: function(event) {
        /* Do something with the selected item */
    }
}

我还创建了一个有效的dojo(尽管未使用angular)。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章