This is a migrated thread and some comments may be shown as answers.

How to put an additional data into grid dataSource

1 Answer 63 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kudryk
Top achievements
Rank 1
Kudryk asked on 08 May 2015, 09:51 AM

I've use the following code to put an additional data into dataSource

var dataSource = new kendo.data.DataSource({
    autoSync: false,
    transport: {
        read: function (options) {
            $.ajax({
                url: get_data.url(),
                dataType: "json",
                success: function (result) {
                    options.success(result);
                },
                error: function (result) {
                    options.error(result);
                }
            });
        },
        update: pushData("update"), create: pushData("create"),
    },
    batch: true,
    "schema": {
        data: "row",
        total: "total",
        rowsdata: "rowsdata",
        model: modelConfig
    },
    group: groupConfig,
    aggregate: aggConfig,
    sort: sortConfig
});

and than I used this data

...
...
 
        var HideParams = function (obj) {
            var g = obj.sender; var hd = undefined;
            if (g && g.dataSource && g.dataSource._pristine && g.dataSource._pristine.rowsdata) hd = g.dataSource._pristine.rowsdata;
            if (hd) {
                for (var i = 0; i < hd.length; i++) {
                    if (hd[i] && hd[i].hidden) g.hideColumn(hd[i].name);
                }
            }
        };
...
...
...
        var gridConfig = {
            dataSource: dataSource,
            ...
            ...
            ...
            dataBound: function (e) {
                if (typeof extDataBound === "function") extDataBound(e);
                if (typeof GridLocate === "function") GridLocate(e);
                if (typeof HideGrouped === "function") HideGrouped(e);
                if (typeof HideParams === "function") HideParams(e);
            },
            ...
            ...
            ...
        };
 
 $("#grid").kendoGrid(gridConfig);

 

But now g.dataSource._pristine is undefined

How I can access rowsdata object in dataSource ?

1 Answer, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 11 May 2015, 02:57 PM

Hello Kudryk,

Indeed there is no _pristine property in the data source. Could you please elaborate a bit more about the "rowsdata" you are trying to access? 

In case of accessing the data items in the data source I would suggest using the data method. The data source view method returns the data items which correspond to the current page, filter, sort and group configuration.

Regards,
Boyan Dimitrov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Kudryk
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Share this question
or