简体   繁体   中英

Create dynamic column Kendo Grid

I am trying to create a dynamic column Kendo Grid using javascript. Now i can generate Columns dynamically. But each time it gives me a error like this.

错误

here is the code i have using

function createDetailsGrid() {
    gridDetails = $("#gridDetails");
    gridDetails.children().remove();
    gridDetails.kendoGrid({
        columns: [],
        dataSource: []

    })

    //var columnSchema = [];
    //columnSchema.push({ title: 'One',field: 'One', width: '100px' });
    //columnSchema.push({ title: 'Two', field: 'Two', width: '100px' });
    var dataSourceContent = GetCustomers();
    var len = dataSourceContent.model.length;

    var columnSchema = [];
    var dataSourceSchema = [];

    for (var i = 0; i < len; i++) {
        columnSchema.push({ title: String(dataSourceContent.model[i].ColumnName), field: String(dataSourceContent.model[i].ColumnName), width: '100px' });
    }
    //for (var i = 0; i < len; i++) {
    //    dataSourceSchema.push({ columnSchema[i].field: 10, smv: 2.3, tot_target: 23 });
    //}

    gridDetails.kendoGrid({
        // .. other properties ..
        columns: columnSchema,
       // dataSource:[],
        pageable: true,
        sortable: true
        //editable: true,
    });

and out put like 网格输出

Is there anything i have missed here?

Thank You

If you dont escape with '\\' it throws an error.

You have to escape the '#' when its presented in your html template like below mentioned:

<a href="\\#dashboard">Dashboard</a>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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