javascript - Kendo UI 网格标题在页面刷新时消失/移动

标签 javascript kendo-ui kendo-grid

我有一个 kendoui 网格,它是从 json 数据源填充的。

每次我的页面重新加载并刷新网格时,我都会看到标题向左移动,最右边的列没有标题!有人见过这个问题吗?我无法在 SO 上找到这种特殊情况的答案。

这是我的网格。我也会发布屏幕截图,但我没有声望点!

感谢任何帮助。

$("#rgrid").kendoGrid({
            sortable: true,
            selectable: true,
            scrollable: false,
            pageable: {
                pageSize: 10,
                refresh: true
            },
            dataSource: {
                transport: {
                    read: "./php/rd.php?action=grd&email=" + $("#tbvalue").val()
                },               
                schema: {
                    model: {
                        fields: {                            
                            c1: {editable: false},
                            c2: {editable: false},
                            c3: {editable: false ,type: "date"},
                            c4: {editable: false, type: "date"},
                            c5: {editable: true, type: "date"}, 
                            c6: {editable: true},
                            c7: {editable: false}                            
                        }
                    },                  
                    data: "data",
                    total: function(response) {
                        return response.total; // total is returned in the "total" field of the response
                    }
                }
            },
            dataBound: function(e) {
                var grid = $("#rgrid").data("kendoGrid");              
                grid.hideColumn(1); // hide the c2 column                
            },
            columns: [
                {
                    field: "c1",
                    title: "c1",
                    width: 150
                }, 
                {
                    field: "c2",
                    title: "c2"
                },
                {
                    field: "c3",
                    title: "c3",
                    format: "{0:yyyy-MM-dd}"
                }, 
                {
                    field: "c4",
                    title: "c4",
                    format: "{0:yyyy-MM-dd}"
                }, 
                {
                    field: "c5",
                    title: "c5",
                    format: "{0:yyyy-MM-dd}"                
                }, 
                {
                    field: "c6",
                    title: "c6",
                    editor: dropDownEditor
                }, 
                {
                    field: "c7",
                    title: "c7"
                },
                { 
                    command: { text: "View", click: doAction}, title: " ", width: "140px" 
                }
            ],
            editable: true
)};

最佳答案

如果您希望某列不显示,而不必手动隐藏它,您应该设置 hiddencolumns 定义中设置为 true。

<div id="grid"></div>
<script>
$("#grid").kendoGrid({
    columns: [
        { hidden: true, field: "id" },
        { field: "name" }
    ],
    dataSource: [ { id: 1, name: "Jane Doe" }, { id: 2, name: "John Doe" } ]
});
</script>

关于javascript - Kendo UI 网格标题在页面刷新时消失/移动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20639079/

相关文章:

kendo-ui - 如何获取 Kendo 网格列宽度

javascript - Kendo Grid 按键事件

javascript - 剑道网格拖放问题

javascript - 从字符串数组分配回调事件 (PIXI.js)

c# - 如何在添加窗口中通过 html 助手更改弹出式剑道网格的标题

javascript - jQuery 函数问题

javascript - 如何使用angularjs将数据传递到kendo窗口

javascript - 如何在不使用 html 包装器的情况下将 View 模型数据绑定(bind)到 Kendo DropDownlist

javascript - 如何将 pug 中的 every 与数组一起使用

javascript - 在 symfony 的 javascript 文件中路由静态 url