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

Can't refresh/reload data combobox

4 Answers 986 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
rooney
Top achievements
Rank 1
rooney asked on 01 Nov 2012, 03:05 AM
i want to make event when some button is clicked, data on combo box is reloaded
this my script, but it's doesn't  work
<div id="example" class="k-content">
            Select a title from Netflix:
            <input id="titles"/>
            <button id="a" />
 
            <script>
                $(document).ready(function() {
                    var aa = $("#titles").kendoComboBox({
                        index: 0,
                        placeholder: "Select City",
                        dataTextField: "name",
                        dataValueField: "id_city",
                        filter: "contains",
                        dataSource: {
                            serverFiltering: true,
                            serverPaging: true,
                            pageSize: 20,
                            transport: {
                                read: "http://localhost/kucarisoft/city"
                            }
                        }
                    });
                    $("#a").click(function (e) {
                        aa.refresh();
                    });
                });
            </script>
        </div>

if i click button a, data on combo box nothing reload

Thank You

4 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 03 Nov 2012, 06:32 AM
Hello,

I tried with below code and also faced same issue in IE while its worked perfectly in FF.

public JsonResult GetCity(string Value)
       {
           int count = DateTime.Now.Second;
 
           List<SelectListItem> lst = new List<SelectListItem>();
 
           for (int i = 0; i < count; i++)
           {
               SelectListItem l1 = new SelectListItem();
               l1.Text = "Name" +i.ToString();
               l1.Value = i.ToString();
               lst.Add(l1);
           }
 
           return Json(lst, JsonRequestBehavior.AllowGet);
       }

<div id="example" class="k-content">
    Select a title from Netflix:
    <input id="titles" />
    <button id="a" onclick="Refreshddl();" />
</div>
<script type="text/javascript">
    $(document).ready(function () {
 
        var newdataSource = new kendo.data.DataSource({
            transport: {
                read: {
                    url: "Home/GetCity",
                    data: {
                        Value: "0"
                    }
                }
            }
        });
 
        var aa = $("#titles").kendoComboBox({
            index: 0,
            placeholder: "Select City",
            dataTextField: "Text",
            dataValueField: "Value",
            filter: "contains",
            dataSource: newdataSource
        });
 
    });
 
 
    function Refreshddl() {
 
        var newdataSource = new kendo.data.DataSource({
            transport: {
                read: {
                    url: "Home/GetCity",
                    data: {
                        Value: "0"
                    }
 
                }
            }
        });
 
        var ddl = $('#titles').data("kendoComboBox");
        ddl.setDataSource(newdataSource);
        ddl.refresh();
 
    }
     
 
</script>


Thanks,
Jayesh Goyani
0
Georgi Krustev
Telerik team
answered on 05 Nov 2012, 09:51 AM
Hello,

 
As it is stated in the docs, the refresh method of the widget does not reload the data of the DataSource. To reload the data use the read method of the dataSource.

All the best,
Georgi Krustev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Jayesh Goyani
Top achievements
Rank 2
answered on 05 Nov 2012, 04:41 PM
Hello,

i agree with you.

Why my above code have different behavior for FF and IE?

Can you please check/explain this issue?

Thanks,
Jayesh Goyani
0
Georgi Krustev
Telerik team
answered on 06 Nov 2012, 12:26 PM
Hello Jayesh,

 
I prepared a simple test page in order to check the behavior of the ComboBox in FF and IE, but everything works as expected. Check this screencast for more information. Let me know if I am missing something.

Kind regards,
Georgi Krustev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
ComboBox
Asked by
rooney
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Georgi Krustev
Telerik team
Share this question
or