Grid generating an HttpPost at document ready

2 posts, 0 answers
  1. Andrea
    Andrea avatar
    11 posts
    Member since:
    Apr 2009

    Posted 09 Jun 2013 Link to this post

    Strange behaviour, really...
    I have an ASP.NET MVC View with a form, and inside of it, a grid that I configure with code like:

    @(Html.Kendo().Grid<Customer>()

                .Name("gridSecondaryCustomers")
                .Columns(columns =>
                {
                        ...

    and then I bind it to local data (JavaScript array) with code like:

            var grid = $("#gridSecondaryCustomers").data("kendoGrid");
            localDataSource = new kendo.data.DataSource({ data: secondaryCustomers });
            grid.setDataSource(localDataSource);

    Last, I add items by code in the array, and refresh the grid with previous code.

    Nothing is showing, so I suppose that the problem lies in the 'normal' configuration of the grid, that tries to go to the server, or something like that...
    So I add this code:

    ...
        .DataSource(ds => { ds.Ajax().ServerOperation(false); })

    and now, magically, when I add an item to the array, I can see the grid populated correctly.

    What puzzles me is that with this single line in the grid configuration, loading the page generates an HttpPost to the controller, that I cannot really track down to where it comes... :-(
    Could you please help me? Please ask me for more information, if needed...
    Thanks as always,
    Andrea
  2. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2289 posts

    Posted 10 Jun 2013 Link to this post

    Hello Andrea,

    I guess you are seeing the initial bind request due to  widget AutoBind setting. If you set it to false it will not attempt to retrieve data until forced (dataSource.read()).

    Regards,
    Nikolay Rusev
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top