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

Event handlers not fired whenever loaded after initial application load

3 Answers 274 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Harlan
Top achievements
Rank 1
Harlan asked on 27 Mar 2015, 07:13 PM
     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)

3 Answers, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 31 Mar 2015, 09:28 AM
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!
 
0
Harlan
Top achievements
Rank 1
answered on 09 Apr 2015, 01:50 PM

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.

 

0
Petyo
Telerik team
answered on 14 Apr 2015, 07:08 AM
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!
 
Tags
General Discussions
Asked by
Harlan
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Harlan
Top achievements
Rank 1
Petyo
Telerik team
Share this question
or