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

Can't refresh/reload data combobox

4 Answers 1181 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!
ömer
Top achievements
Rank 1
commented on 21 Jul 2024, 09:10 AM

read was working, i stared to add new features to my existing project but noticed that read method not working, i call read method the  requestStart and requestEnd methods not triggered and also no network traffic exists when pressed F12, there is no failure alert

    console.log("reloadBrancheStore");
    brancheStore.options.transport.read.data.areaId = getAreaIdsForUrl();
    brancheStore.options.transport.read.data.cityIds = getCityIds();
    brancheStore.options.transport.read.data.companyIds = getCompanyIds();
    console.log("reloadBrancheStore before  read");
    brancheStore.read();
    console.log("reloadBrancheStore after read");

 

ömer
Top achievements
Rank 1
commented on 21 Jul 2024, 09:11 AM

relaoded old code base from vsts and still read does not works.
Neli
Telerik team
commented on 24 Jul 2024, 03:17 PM

Hi,

Here you will find a small example where on a button click the dataSource read method is called and the returned data is loaded in a Grid.

I will appreciate any detail on how the behavior on your side can be replicated. Could you please try to prepare a Dojo example and send it back.

Regards,

Neli

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