jQWidgets Forums

jQuery UI Widgets Forums Plugins AngularJS jqxgrid – virtualmode, and bindingcomplete

This topic contains 3 replies, has 2 voices, and was last updated by  Peter Stoev 9 years, 10 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author

  • badera
    Participant

    Dear all

    There is an issue in jqxgrid with angularJS, if we setup for virtualmode and therefore have a “beforeprocessing” function in the source defined (to adapt source.totalrecords) and also have a bindingcomplete function in the settings of the grid.

    We can easily reproduce the problem even without virtual mode enabled: Try this sample:

    
    <!DOCTYPE html>
    <html ng-app="demoApp">
    <head>
        <title id="Description">jqxGrid Binding to JSON using AngularJS</title>
        <link rel="stylesheet" type="text/css" href="../../jqwidgets/styles/jqx.base.css" />
        <script type="text/javascript" src="../../scripts/jquery-1.11.1.min.js"></script>
        <script type="text/javascript" src="../../scripts/angular.min.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqx-all.js"></script>
        <script type="text/javascript">
            var demoApp = angular.module("demoApp", ["jqwidgets"]);
    
            demoApp.controller("demoController", function ($scope, $http) {
                $scope.gridSettings =
                {
                    altrows: true,
                    width: '100%',
                    height: '100%',
                    source:  {
                        datatype: "json",
                        datafields: [
                            { name: 'name', type: 'string' },
                            { name: 'type', type: 'string' },
                            { name: 'calories', type: 'int' },
                            { name: 'totalfat', type: 'string' },
                            { name: 'protein', type: 'string' }
                        ],
                        id: 'id',
                        url: "../sampledata/beverages.txt",
    
                        beforeLoadComplete: function (records) {
                            return records;
                        },
    
                        loadComplete: function (data) {
                        },
    
                        filter: function()
                        {
                        },
    
                        sort: function()
                        {
                        },
    
                        beforeprocessing: function (data) {
                            this.totalrecords = 10000;
                        }
                    },
                    filterable: true,
                    showfilterrow: true,
                    
                    rowselect: function (event) {
                        console.log("grid.rowselect");
                    },
                    
                    columns: [
                      { text: 'Name', datafield: 'name', width: 250 },
                      { text: 'Beverage Type', datafield: 'type', width: 250 },
                      { text: 'Calories', datafield: 'calories', width: 180 },
                      { text: 'Total Fat', datafield: 'totalfat', width: 120 },
                      { text: 'Protein', datafield: 'protein', minwidth: 120 }
                    ],
    
                    rendergridrows: function (obj) {
                        return obj.data;
                    },
    
                    bindingcomplete: function (event) {
                        console.log("binding is completed");
                    }
    
                }
            });
        </script>
    </head>
    <body>
        <div ng-controller="demoController">
            <jqx-grid jqx-settings="gridSettings"></jqx-grid>
        </div>
    </body>
    </html>
    

    And you will get an “undefined is not a function” error in JavaScript Console.
    -> It works, if we remove the bindingcomplete function
    -> It also works, if we remove “this.totalrecords = 10000” from source.beforeprocessing; however, this is neccessary for virtualmode.

    Is there a workaround? Fix?
    Thanks in advance!
    – badera


    Peter Stoev
    Keymaster

    hi badera,

    If it’s virtual mode, then why virtualmode: true is missing from your code?

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com


    badera
    Participant

    Dear Peter

    I think that it is usually easier to trace down a problem, if we enable as little features as possible – and that is the point: The issue arrives, if this.totalrecords = 10000 is set in source.beforeprocessing. This can of course be done without ‘virtualmode: true’ in the settings. But it does only make sense in virtualmode…

    However, if you only give a useful answer, if virtualmode: true is set in the settings, feel free to do it 🙂

    It is still an issue for me, so I would be happy to get a workaround. Please fix this for the next release! Thanks!
    – badera


    Peter Stoev
    Keymaster

    Hi badera,

    I asked you that because I am unable to reproduce an issue when virtualmode is set to true in the current version.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.