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

[Solved] Controller action hit twice when calling .read()

1 Answer 1600 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Flores
Top achievements
Rank 1
Flores asked on 28 Mar 2012, 09:42 AM

Hi Kendo team,

I am having a strange issue with a datasource that is feeding some charts.
The datasource looks like this:

var chartDs = new kendo.data.DataSource({
            transport: {
                read: {
                    url: "Export/GetReportHistory",
                    type: "POST",
                    dataType: "json",
                    data: {
                        numberOfMonths: function () {
                            return $("#chartTimeFrame").val();
                        }
                    }
                }
            }
        });

This is works fine as it is, but when the page is loaded (document.ready) my server action (MVC3) is hit twice.
That means data is returned twice and the chart animation is run twice :-\

A dropdownlist on my page reloads the charts based on different data, when this event is triggerd, the server is also hit twice in a row displaying the behavior described above.

$("#chartTimeFrame").change(function () {
            $("#reportChart").data("kendoChart").dataSource.read();
            $("#damageChart").data("kendoChart").dataSource.read();
            $("#defectChart").data("kendoChart").dataSource.read();
        });

I can't seem to find the source of the problem so I hope you can help me out :-( (and it makes the charts animations look strange bouncing up and down when they are reloaded).

Update:
It seems this has been asked before (I should have searched a little further before posting)
and the answer can be found here: http://www.kendoui.com/forums/framework/data-source/shared-datasource---each-ui-element-seems-to-read.aspx

Sorry for double posting :-(

1 Answer, 1 is accepted

Sort by
0
Paul
Top achievements
Rank 1
answered on 08 Oct 2014, 05:56 PM
Please note, in my case this double posting ended up being a javascript call to change the page followed by a read call.  The read call is redundant as setting the grid's page will already cause it to requery data.
From:
grid.dataSource.page(1);
grid.dataSource.read();
To:
grid.dataSource.page(1);
Tags
Data Source
Asked by
Flores
Top achievements
Rank 1
Answers by
Paul
Top achievements
Rank 1
Share this question
or