Grid remote parameterized data virtualization transport.read method

3 posts, 0 answers
  1. Rocio
    Rocio avatar
    28 posts
    Member since:
    Dec 2015

    Posted 01 Aug Link to this post

    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. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    1746 posts

    Posted 03 Aug Link to this post

    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.
     
  3. Kendo UI is VS 2017 Ready
  4. Rocio
    Rocio avatar
    28 posts
    Member since:
    Dec 2015

    Posted 09 Aug in reply to Boyan Dimitrov Link to this post

    I realized by assigning the variables outside the grid and then calling them on the function did the trick.  Thank you Boyan.
Back to Top