kendo-labs / angular-kendo

A project to create a robust set of Angular.js bindings for Kendo UI widgets
474 stars 209 forks source link

Multiselect selected values on load via ajax datasource and k-ng-model #400

Open brentlyjdavid opened 9 years ago

brentlyjdavid commented 9 years ago

I am having trouble getting this to work. I currently am using the code as this demo describes, but i'm having the same problem this demo: http://docs.telerik.com/kendo-ui/web/multiselect/how-to/AngularJS/pre-select-items It simply refuses to load the pre-selected items on the ajax data sources. even though i set the model with k-ng-model.

I have no errors, and all the data is loaded correctly when i use the control except my initial selected values aren't showing up. Can you point me in a good direction to fix this?

 <select kendo-multi-select k-rebind="projectSelectionIdOptions" k-options="projectSelectionIdOptions" k-ng-model="mySelections.selectedIds" style="width: 550px;"></select>
$scope.projectSelectionIdOptions = {
            placeholder: "All Projects",
            dataValueField: "Id",
            dataTextField: "DisplayName",
            valuePrimitive: true,
            change: function(e) {
                //change event
            },
            dataSource: {
                transport: {
                    read: {
                        url: "/AjaxLoading/GetProjectSelections?includeInactive=false",
                        dataType: "json",
                    },
                },
                group: { field: "ClientName" }
            },
            htmlAttributes: {
                style: "width: 550px;",
            }
        };

this is my populated scope variable that contains my array of values (it has other data too as one big object, but the values are in this response.data, i did check that).

$http.get('/api/userprofiles/myselections').then(function (response) {
            $scope.mySelections = response.data;
        }, function (response) {
            //error on api call
        });
brentlyjdavid commented 9 years ago

As an update, this method seems to work fine for the drop down list control. just not the multi-select.