【问题标题】:Database driven Kendo Grid column数据库驱动的剑道网格列
【发布时间】:2014-02-11 01:28:45
【问题描述】:

是否可以枚举来自数据库表的网格列,例如(标题和宽度)?

【问题讨论】:

    标签: kendo-ui kendo-grid kendo-asp.net-mvc


    【解决方案1】:

    您需要为此进行 ajax 调用。从表中派生列名,然后您可以进行修改。

    例如

    $.ajax({ 
        url:actionUrl, //Url of the Method for fetching names of the columns and its count
        success: function(result){
            for (var i = 0; i < result.columnsCount; i++) { //running the loop based on number of columns needed
                columns.push({ 
                    field: result.columnName, //set the columnNames from the Db as field
                    title: result.Header //specifying the columns title
                }); 
            }
        } 
    }); 
    

    【讨论】:

    • 哇,谢谢先生.. 试试这个。我希望我能得到这个,我是 mvc 和 kendo ui 小部件的新手。谢谢
    【解决方案2】:

    您可以尝试以下方法:

    $(document).ready(function() {
            var model = kendo.observable({
                gridRows: []
            });
    
        var columns = [];
    
        for (var i = 0; i < 4; i++) {
            var entryIndex = "entries[" + i + "]";
            columns.push({
                field: i,
                title: "Column " + i
    
            });
        }
    
        var configuration = {
            resizable: true,
            columns: columns
        };
    
        var timeEditGrid = $("#grid").kendoGrid(configuration).data("kendoGrid");
    
    
        kendo.bind($('#example'), model);
    }); 
    

    http://jsfiddle.net/4sM7g/

    【讨论】:

    • 谢谢!!我有可能从表格中获取列列表吗? kendo ui 具有 LoadColumnSettings 功能,但它已传递给来自控制器中数组的视图数据。建议很受欢迎。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多