简体   繁体   中英

KendoUI chart not reflecting datasource change

I'm trying to update kendo chart datasource when user fills out a form indicating the product id to graph (units sold) and touching the update button.

I catch the touch and change datasource's url (as Im passing product id as GET parameter) and change DS's url to the value on the text field.

Im pretty sure it is requesting the correct url with the correct parameter (id) but somehow kendo chart is not refreshing which is very frustrating.

Any help? M

DS

var dsByUnits = "libyPrds.php?way=byUnits&prodID=-1";
        var dsByMoney = "libyProducts.php?way=byMoney&prodID=-1";

        var byUnitsDataSource = new kendo.data.DataSource({
                            transport:{
                                read:dsByUnits,
                                dataType: "json"
                            }});

Update

$(document).ready(function() {


                $("#btProd").click(function () {
                    dsByUnits = "libyPrds.php?way=byUnits&prodID="+$("#prodID").val();


                    byUnitsDataSource = new kendo.data.DataSource({
                            transport:{
                                read:dsByUnits,
                                dataType: "json"
                            }});


                    byUnitsDataSource.read();
                });

            });

There is no code which actually binds the chart to the newly created data source. This means that the chart will never know that your data has changed. You should use the data source instance to which the chart is bound not create a new one. Something like this:

$("#chart").data("kendoChart").dataSource.read();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM