0

I have a textbox for which I added kendoAutoComplete function. This is working fine. However, I wanted to set some value to this textbox upon the page load (I get the value from DB). With KendoAutoComplete, I am unable to set this.

I can either implement KendoAutoComplete or set datsource. Both of them work fine separately. Where as, if I include the code related to both - it doesnt work. Below is the code. Can you please throw me some inputs if you have come across this issue?

myController.js

$("#txtPartNumbers").kendoAutoComplete({
            dataSource: {
                serverFiltering: true,
                enforceMinLength: true,
                transport: {
                    read: {
                        url: ApiBaseUrl.val + 'inventoryLocation/getParts',
                        type: "get",
                        dataType: "json",
                        data: function () {
                            return { partNumber: $scope.autoCompleteText }
                        }
                    }
                },
            },
            change: function(e) {
                $scope.autoCompleteText = this.value();
            },
            filter: "startswith",
            //placeholder: "Select Inventory Parts..",
            minLength: 3,
            separator: ", "
        });

cshtml

<div class="sectionFloatLeft">
   <label>Part Number(s):</label><br />
   <input id="txtPartNumbers" type="text" ng-model="filterByPartNumbers" class="form-control filterTextArea" style="width: 300px;height:80px;" placeholder="Enter Part Numbers (Comma sepatared)" />
</div>

I am setting "filterByPartNumbers" value in my controller

....
var data = getDataFromDB();
$scope.filterByPartNumbers = data.partNumbers;
...

Appreciate you help.

code.cycling
  • 1,246
  • 2
  • 15
  • 33
Neelima Ediga
  • 346
  • 1
  • 5
  • 19

1 Answers1

0

I was able to set the value as below:

$("#txtPartNumbers").data("kendoAutoComplete").value(data.partNumbers);

Thanks!

Neelima Ediga
  • 346
  • 1
  • 5
  • 19