简体   繁体   English

将Kendo网格绑定到复杂数据源

[英]Binding Kendo grid to a Complex dataSource

I have a div which I am converting to a Kendo Grid in Jquery. 我有一个div,它将在Jquery中转换为Kendo网格。

 divSearchGrid.kendoGrid({
    dataSource: {
        transport: {
            read: function (options) {
                var webMethod = "Portal.aspx/DisplayNotes";
                $.ajax({
                    type: "POST",
                    url: urlSearch,
                    data: paramsSearch,
                    async: false,
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (result) {
                        options.success(result.d);
                    }
                })
            }
        }
    },
    batch: true,
    selectable: "row",
    autoSync: true,
    editable: true,// "inline",
    navigatable: true,
    columnMenu: true
})

It's Datasource is a List whose objects has another List as their properties. 它的数据源是一个List,其对象具有另一个List作为其属性。

Example Datasource : [{a,b,c,List,g,h,i,},{a,b,c,List,g,h,i,},{a,b,c,List,g,h,i,}] 示例数据源: [{a,b,c,List,g,h,i,},{a,b,c,List,g,h,i,},{a,b,c,List,g,h,i,}]

and the List in above objects has following structure 并且上述对象中的列表具有以下结构

List : [{d},{e},{f}] 清单[{d},{e},{f}]

I want to show my kendo grid with following columns: 我想用以下几列显示我的Kendo网格:

a,b,c,d,e,f,g,h,i A,B,C,d,E,F,G,H,I

How can I achieve this functionality. 如何实现此功能。

If you just need to show the contents, you can simply bind multiple columns to the List object, and use the template property to display each one. 如果只需要显示内容,则只需将多列绑定到List对象,然后使用template属性显示每一列。

{ field: 'List', template: '#=List[0].value#' }

or similar. 或类似。 Of course it relies on List having the same number of properties for each main list Item (ie always {d},{e},{f}). 当然,它依赖于List具有每个主列表项相同数量的属性(即始终为{d},{e},{f})。

If you need to edit these fields, you will need to employ a custom editor for each {d},{e},{f} field 如果您需要编辑这些字段,则需要为每个{d},{e},{f}字段使用自定义编辑器

Here is a small sample using a list with a nested list. 这是一个使用嵌套列表的小样本。 (Second grid is just for testing actual values are changing). (第二个网格仅用于测试实际值是否正在更改)。 Not exactly sure how your data is structured, or what your data types are, but hopefully this will help. 不完全确定数据的结构或数据类型是什么,但是希望这会有所帮助。

http://jsbin.com/AWogIpO/1/edit http://jsbin.com/AWogIpO/1/edit

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM