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

AngularJS: MultiSelect.options.dataSource Does Not Load If Resolved In A Promise

3 Answers 117 Views
Integration with other JS libraries
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 28 Aug 2014, 03:36 AM
Hello,

I have found this issue in several of the Kendo UI (when integrated with AngularJS) controls and wanted to see what I'm doing wrong.

The underlying issue is this.  If my controller calls to a data provider (i.e., an AngularJS factory that then calls to a backend Rest service) that resolves data (returned from the Rest service) and then sets the MultiSelects options.dataSource configuration to that result, the multiselect list is not filled.  If I just fill the options.dataSource with stub data outside of the factory call, everything works fine - but this isn't realistic.

I have attached a zip file (containing a Kendo Dojo Html file) that demonstrates the issue.  I was able to reproduce this by just using (for Dojo purposes) a $watch service to simulate the data provider call/resolution.  I can expand the repro to use a factory and hard code the data and resolve that data, if necessary.

The company I work for has a commercial license, but it's late, and I don't have the account information (I'm logged in with an account I created to get the Trial version).  We have support tickets.  I can get you this information tomorrow if it's necessary...I just need help figuring this out.

Thank you so much!!
 
-Mark

3 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 28 Aug 2014, 07:03 AM
Hi Mark,

I this case you should use the k-rebind attribute. More info is available in the angular documentation.

Regards,
Atanas Korchev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Mark
Top achievements
Rank 1
answered on 28 Aug 2014, 02:35 PM
That was it!  Thanks so much Atanas!

One more question...

Looking at another way to do this (as to avoid using options.dataSource and k-rebind  - as that seems a bit much to me), I set k-data-source along with k-ng-model (to select the appropriate items) and it worked great.  One thing I did notice about this though was if I initialize the selected items data (for k-ng-model) before initializing the k-data-source, then my options from k-ng-model would not bind and be shown as selected.

How can I achieve this?  This seems so much more straightforward to keep the data source separate from the options.

Let me know and I can attach the Kendo Dojo Html zip where I experimented with this.

Thanks again,
Mark
0
Mark
Top achievements
Rank 1
answered on 28 Aug 2014, 03:57 PM
I figured it out.

It actually comes back around to the k-rebind directive and setting it appropriately.  In this case, it needs to be set to the data source on my $scope that the k-data-source directive is set to.

Thanks for your help!!

-Mark
Tags
Integration with other JS libraries
Asked by
Mark
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Mark
Top achievements
Rank 1
Share this question
or