Event handlers not fired whenever loaded after initial application load

4 posts, 0 answers
  1. Harlan
    Harlan avatar
    19 posts
    Member since:
    Dec 2014

    Posted 27 Mar 2015 Link to this post

         I am building a web application which makes use of kendo UI  and angular-kendo.  The problem that I'm having is that the change event handlers, when specified in code, are never fired.

    Example:

    01.$scope.gridData = new kendo.data.DataSource({
    02.        data: [{ "Id": 1 }, { "Id": 2 }],
    03.        change: function (event) {
    04.            // TODO:  Save sort to localstorage.
    05.            console.log("CHANGE FIRE");
    06. 
    07.            var sort = $scope.gridSort = this.sort(); //contactsGrid.dataSource.sort();
    08. 
    09.            var sortString = getSortString(sort);
    10. 
    11.            if (sortString != lastSortString) {
    12.                var sortCopy = angular.copy(sort);
    13. 
    14.                contactsService.get((gridPager.page() - 1) * gridPager.pageSize(), gridPager.pageSize(), sortString).then(parseContacts);
    15. 
    16.                lastSortString = sortString;
    17.            }
    18.        }
    19.    });

    Whenever this is loaded at initial load of the application, the change event will fire.  If it gets loaded in a controller at a later time (think switching routes in ngRouter, or states in angular-ui-router), the change event will not get fired.

    If I specify the k-on-change directive, like this:
    <div kendo-pager k-options="pagerOptions" k-on-change="pagerChange()" id="gridPager"></div>
    the specified change handler will fire, no matter when the HTML gets loaded.

    The problem isn't just with the datasource.change event either.  The kendoPager.chancge event didn't work either when in code.

    What does angular-kendo do differently at initial page load than at a partial view load that would cause that problem?  Is there a way to work around it? (Aside from specifying k-on-change)
  2. Alexander Valchev
    Admin
    Alexander Valchev avatar
    2894 posts

    Posted 31 Mar 2015 Link to this post

    Hi Harlan,

    Change event of the dataSource should fire every time the dataSource's data changes.
    I prepared a small test page which uses AngularJS syntax: http://dojo.telerik.com/IFAgi

    Try to sort the data and watch the console. On my side everything works as expected.What am I missing?

    Regards,
    Alexander Valchev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. Harlan
    Harlan avatar
    19 posts
    Member since:
    Dec 2014

    Posted 09 Apr 2015 in reply to Alexander Valchev Link to this post

    You were missing partials and templates.  I edited your example to more closely match the configuration in which I'm trying to use angular-kendo.  The odd thing about this is that the example works in circumstances that my code didn't, so I'm not sure what's exactly wrong with it.  http://dojo.telerik.com/IFAgi/4

    I've decided to just use the jQuery functions for now.

     

  4. Petyo
    Admin
    Petyo avatar
    2444 posts

    Posted 14 Apr 2015 Link to this post

    Hello,

    as far as I see, your example works correctly. If you manage to replicate the issue in a dojo, please send it to us - we should be able to help you further. 

    Regards,
    Petyo
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
Back to Top