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

Grid remote parameterized data virtualization transport.read method

2 Answers 41 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rocio
Top achievements
Rank 1
Rocio asked on 01 Aug 2016, 01:54 PM

Thank you in advance for any feedback:

1) Am I defining correctly the parameters to be passed on my vm.audit.load function on the grid data source?

$(document).ready(function () {
    var vm = kendo.observable(fhfa.vm.default({
        container: $("#app-main"),
        appVersion: audit.constants.appVersion
    }));

    //***grid data***
    var o = audit.auditCollection({});
    vm.set("audit", o);

   // kendo.bind($("#app-main"), vm);

 

     $("#grid").kendoGrid({
        //data: vm.audit.load,

        dataSource: {
            p : function(){

                //*** Search criteria values ***
                var auditTypeCB = $("#auditType").data("kendoComboBox");
                auditTypeID: checkIfZeroOrBlank(auditTypeCB.select());

                startDate: checkIfZeroOrBlank($("#sDate").val());
                endDate: checkIfZeroOrBlank($("#eDate").val());

                var applicationCB = $("#appDropDownList").data("kendoComboBox");
                applicationID: checkIfZeroOrBlank(applicationCB.select());

                auditUser: checkIfZeroOrBlank($("#user").val());
                ipAddress: checkIfZeroOrBlank($("#ipAddress").val());
                auditDescription: checkIfZeroOrBlank($("#description").val());

                pageOffset: null;
                pageSize: 0;
                orderBy: null;
                orderByDirection: null
            },
            schema: {
                data: "audit.items"
            },
            transport: {
                read: function (options) {
                    vm.audit.load(p.applicationID, p.auditTypeID, p.auditUser, p.ipAddress, p.startDate, p.endDate, p.auditDescription, p.pageOffset, p.pageSize, p.orderBy, p.orderByDirection, p.pageMax).then(function () {
                        options.success(data);
                    });
                }
            }
        },
        columns: [{
            field: "applicationID",
            hidden: true
        },
        {
            field: "auditTypeID",
            title: "Type"
        },
        {
            field: "auditDate",
            title: "Date",
        },
        {
            field: "applicationName",
            title: "Application",
        },
        {
            field: "auditUser",
            title: "User"
        },
        {
            field: "iPAddress",
            title: "IP Address"
        },
        {
            field: "auditDescription",
            title: "Description"
        }],
        scrollable: true,
        groupable: true,
        reorderable: true,
        sortable: true,
        selectable: true
    });

 

 audit.auditCollection = function (init) {
    var o = fhfa.object.baseCollection(init);
    o._name = "auditCollection"
    o._createObject = function () {
        return audit.audit(init);
    };
    o.onloading = function (args) {
        vm = this;
        kendo.ui.progress(vm._view.element, args.isLoading);
    };
    o.load = function (applicationID, auditTypeID, auditUser, ipAddress, startDate, endDate, auditDescription, pageOffset, pageSize, orderBy, orderByDirection, pageMax) {
        var that = this;

        var vPageSize = 100;
        var vCount = 0;
        var def = $.Deferred();
        that._isLoading = true;

        if (pageSize === 0) {
            pageSize = vPageSize;
        }

        audit.da.auditItems_get(applicationID, auditTypeID, auditUser, ipAddress, startDate, endDate, auditDescription, pageOffset, pageSize, orderBy, orderByDirection, vPageSize, pageMax).done(function(eResult) {
            var items = eResult.d.auditItems;
            vCount = eReResult.d.auditItems.lenght;
            that.set("total", vCount);
            that.addArray(items);

            def.resolve(that);
        }).fail(function (error) {
            if (init.onerror) init.onerror({ source: that, sourceType: that._name, error: error });
            def.resolve(that);
        }).always(function () {
            that._isloading = false;
        });     

        return def.promise();
    };

2 Answers, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 03 Aug 2016, 01:41 PM

Hello Rocio,

In this case I think it is no necessarily  to have a specific function p inside the DataSource object. Also please make sure that the data passed to the options.success of the read function is an array of data. If the array containing the data items is a nested field in the response access the array and pass it to the success callback. 

read: function (options) {
                   vm.audit.load(p.applicationID, p.auditTypeID, p.auditUser, p.ipAddress, p.startDate, p.endDate, p.auditDescription, p.pageOffset, p.pageSize, p.orderBy, p.orderByDirection, p.pageMax).then(function () {
                       //if data array is placed in data field of the response
                       options.success(data.data);
                   });
               }

 

Regards,
Boyan Dimitrov
Telerik by Progress
 
Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
 
0
Rocio
Top achievements
Rank 1
answered on 09 Aug 2016, 12:57 PM
I realized by assigning the variables outside the grid and then calling them on the function did the trick.  Thank you Boyan.
Tags
Grid
Asked by
Rocio
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Rocio
Top achievements
Rank 1
Share this question
or