简体   繁体   中英

get cell text in kendo grid

I need to get the displayed text of a kendo grid, while iterating over the data. I have bee doing this:

    var data = grid.dataSource.data();
    var cols = grid.columns;

    for (var ri = 0; ri < data.length; ri++) {
        for (ci = 0; ci < cols.length; ci++) {
            var val = data[ri].get(cols[col].field);
            //do something with the cell data
            //but this gets me the model's value, not the displayed text
        }
    }

How can I get the displayed text in each cell?

Ok, figured it out.

        var data = grid.dataSource.data();
        var cols = grid.columns;
        var field, template;

        for (var ri = 0; ri < data.length; ri++) {
            for (ci = 0; ci < cols.length; ci++) {
                field = cols[ci].field;
                template = cols[ci].template;
                if (field) {
                    var textval = data[ri][field];

                    if (template) {
                        var kt = kendo.template(template.toString());
                        textval = kt(data[ri]);
                        valType = 'string';
                    }

                    //do something with textval here
                }
            }
        }

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