Kendo-grid锁定列和分组

时间:2014-10-23 09:14:13

标签: kendo-ui kendo-grid

我有一个带有锁定(冻结)列的网格,并像这样分组:

demos.telerik.com/kendo-ui/grid/frozen-columns

但我只有一个冷冻柱和小宽度。

当我按列分组长字符串值(例如船舶地址)时,组标题中的这些组值以多行显示。

Screen

即使网格的第一部分(带锁定列)宽度较小,如何在一行中显示组标题? Source

 $(document).ready(function() {
        $("#grid").kendoGrid({
            dataSource: {
                type: "odata",
                transport: {
                    read: "http://demos.telerik.com/kendo-ui/service/Northwind.svc/Orders"
                },
                schema: {
                    model: {
                        fields: {
                            OrderID: { type: "number" },
                            ShipCountry: { type: "string" },
                            ShipName: { type: "string" },
                            ShipCity: { type: "string" },
                            ShipAddress: { type: "string" }
                        }
                    }
                },
                pageSize: 30,
                group: { field: "ShipName" } 
            },
            height: 540,
            sortable: true,
            reorderable: true,
            groupable: true,
            resizable: true,
            filterable: true,
            columnMenu: true,
            pageable: true,
            columns: [ {
                    field: "OrderID",
                    title: "Order ID",
                    locked: true,
                    lockable: false,
                    width: 50
                }, {
                    field: "ShipCountry",
                    title: "Ship Country",
                    width: 300
                }, {
                    field: "ShipCity",
                    title: "Ship City",
                    width: 300
                },{
                    field: "ShipName",
                    title: "Ship Name",
                    width: 300
                },  {
                    field: "ShipAddress",
                    width: 400
                }
            ]
        });
    });

1 个答案:

答案 0 :(得分:1)

<强>解

来自telerik的Alexander Popov写道:

$(document).ready(function() {
        $("#grid").kendoGrid({
          dataBound: function(e){
            var grid = this;
            this.lockedTable.find(".k-grouping-row").each(function(index) {
              var arrow = $(this).find("a");
              grid.tbody.find(".k-grouping-row:eq("+index+") td").text($(this).text())
              $(this).find("p").text(" ").append(arrow);
            })
          },
            dataSource: {
                type: "odata",
                transport: {
                    read: "http://demos.telerik.com/kendo-ui/service/Northwind.svc/Orders"
                },
                schema: {
                    model: {
                        fields: {
                            OrderID: { type: "number" },
                            ShipCountry: { type: "string" },
                            ShipName: { type: "string" },
                            ShipCity: { type: "string" },
                            ShipAddress: { type: "string" }
                        }
                    }
                },
                pageSize: 30
            },
            height: 540,
            sortable: true,
            reorderable: true,
            groupable: true,
            resizable: true,
            filterable: true,
            columnMenu: true,
            pageable: true,
            columns: [ {
                    field: "OrderID",
                    title: "Order ID",
                    locked: true,
                    lockable: false,
                    width: 50
                }, {
                    field: "ShipCountry",
                    title: "Ship Country",
                    width: 300
                }, {
                    field: "ShipCity",
                    title: "Ship City",
                    width: 300
                },{
                    field: "ShipName",
                    title: "Ship Name",
                    width: 300
                },  {
                    field: "ShipAddress",
                    lockable: false,
                    width: 400
                }
            ]
        });
    });