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

Autocomplete Refresh

3 Answers 265 Views
AutoComplete
This is a migrated thread and some comments may be shown as answers.
Jean-Yves
Top achievements
Rank 1
Jean-Yves asked on 03 Aug 2012, 01:06 PM
In love with Kendo UI but not with refresh which does not fire.
We tried different methods without success
Inside an ascx UserControl this is our code:

    <div style="width:1100px;margin:40px 0 100px 0;text-align:center">
        <input id="comboboxWarrantyClients" style="width:200px" />
        <br /><br />
        <div id="button">Refresh the autocomplete !</div>
    </div>
  <script type="text/javascript">
    var kendoAutoCompleteWC = null;
    $(document).ready(function () {
      kendoAutoCompleteWC = $("#comboboxWarrantyClients").kendoAutoComplete({
        dataTextField: "FullName",
        dataValueField: "ID",
        dataSource: [{"ID":1,"FullName":"John"}],
        filter: "contains",
        placeholder: "Select"
      });
    });
    $('#button').click(function () {
      kendoAutoCompleteWC.dataSource = [{"ID":1,"FullName":"John"},{"ID":2,"FullName":"Nathalie"}];
      kendoAutoCompleteWC.refresh();
    });

Can someone has the trick to make it work, please ?
In this case, we get an error "kendoAutoCompleteWC.refresh(); is not a function..."
Thanks so much by advance...
Jean Yves




3 Answers, 1 is accepted

Sort by
0
Accepted
John DeVight
Top achievements
Rank 1
answered on 07 Aug 2012, 02:33 PM
Hi Jean,

There were 2 things that I needed to do.  First, I needed to change the way that kendoAutoCompleteWC variable is getting set by adding .data("kendoAutoComplete") to the end of the statement.  Second, instead of setting the .dataSource property and then calling .refresh, I called the .setDataSource function.

Here is the code:

var kendoAutoCompleteWC = null;
$(document).ready(function () {
  kendoAutoCompleteWC = $("#comboboxWarrantyClients").kendoAutoComplete({
    dataTextField: "FullName",
    dataValueField: "ID",
    dataSource: [{"ID":1,"FullName":"John"}],
    filter: "contains",
    placeholder: "Select"
  }).data("kendoAutoComplete");
});
$('#button').click(function () {
  kendoAutoCompleteWC.setDataSource([{"ID":1,"FullName":"John"},{"ID":2,"FullName":"Nathalie"}]);
});

Hope that helps.

Regards,

John DeVight
0
Jean-Yves
Top achievements
Rank 1
answered on 08 Aug 2012, 06:59 AM
Dear John,

It helps a lot!
Works perfectly!
We have got knowledge here.
Thanks for the time you spent on this issue which had concerned us a lot.

With my Best Regards

Jean Yves from France
0
John DeVight
Top achievements
Rank 1
answered on 08 Aug 2012, 11:51 AM
Glad to hear that worked for you :)

Regards,

John DeVight
Tags
AutoComplete
Asked by
Jean-Yves
Top achievements
Rank 1
Answers by
John DeVight
Top achievements
Rank 1
Jean-Yves
Top achievements
Rank 1
Share this question
or