Display DataSource data on Grid Rows (not columns)

3 posts, 0 answers
  1. Larissa
    Larissa avatar
    19 posts
    Member since:
    Dec 2015

    Posted 24 Feb 2016 Link to this post

    There is a way to display the dataSource as rows and not columns?

    My dataSource has only one record with 30 properties. I would like to display the properties as rows (property1 => row1, property2 => row2, ...) instead of columns (property1 => column1, property2 => column2, ....).

    In fact, I would like to retrieve 3 records (each one with 30 properties), but the 3 records would be the colums and the common 30 properties would be the rows.

    How can I do that?

  2. Larissa
    Larissa avatar
    19 posts
    Member since:
    Dec 2015

    Posted 25 Feb 2016 Link to this post

    This is what I did so far, but I'm not sure this is the right way.

     

    var _dataSource = function () {
     
            var dataSource = new kendo.data.DataSource({
                transport: {
                    read: { // returns only 3 records
                        url: url,
                        dataType: "json"
                    }
                },
                schema : {
                    data: "data",
                    total: "total",
                    parse: function (data) {
     
                        console.log(data);
                        var dataArray = [];
                        var i = 0;
                        for (var property in data[0]) {
     
                            console.log(property);
                            console.log(data[0][property]);
     
                            var record = {
                                header: "",
                                headerId: "",
                                record1: "",
                                record2: "",
                                record3: ""
                            };
     
                            record.header = headerRows[i]; // array of header string (the 30 properties)
                            record.headerId = property;
                            record.record1 = data[0][property];
                            record.record2 = data[1][property];
                            record.record3 = data[2][property];
     
                            console.log(record);
     
     
                            dataArray.push(record);
                            i++;
                        }
                        return dataArray;
                    }
                }
            });
     
            return dataSource;
        };

    But this gives the error: TypeError: e is undefined

  3. Larissa
    Larissa avatar
    19 posts
    Member since:
    Dec 2015

    Posted 25 Feb 2016 Link to this post

    Got it! So simple!
    Instead of build the logic on schema, I did it on data.
    Actually, it makes more sense on data. Don't know why I was trying on schema.
Back to Top