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

[Solved] Grid Population Ajax vs Server binding

3 Answers 109 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
David
Top achievements
Rank 1
David asked on 24 May 2012, 04:59 PM
When you turn on AJax binding for a grid and pass in a a collection of data to

Html.Telerik().Grid(data)

Why does the grid do a subsequent ajax request once the grid is rendered in the browser. It was my understanding that the ajax request would only be used for paging/sorting/filtering.

Is there anyway to avoid this. From a UX perspective it is much better if the page loads with the grid already contain the first page of data. At that point no ajax request is needed since the data it is going to get back is redundant.

3 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 25 May 2012, 08:53 AM
Hi,

 The grid shouldn't make an ajax request in this case. This behavior can be observed in our first look demo: http://demos.telerik.com/aspnet-mvc/grid 

All the best,
Atanas Korchev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now.
0
David
Top achievements
Rank 1
answered on 12 Jun 2012, 01:29 AM
I looked over the network call logs from fiddler and I realized what the issue is. if the table is populated with data from the server. no ajax call is made. However, if the table is populated with an empty collection. an ajax call is still made. I suspect the decision to make the ajax call is checking to see if there are already rows in the table and if there isnt then does an AJAX call. I would view this as a defect as your effectively doing two queries in short succession. Once when the page is loaded and again on document ready when the client side code sees an ajax bound table that does not have any data in it from the server.
0
Atanas Korchev
Telerik team
answered on 12 Jun 2012, 06:57 AM
Hi,

 Yes this is what the grid is doing - when empty it makes an ajax request to populate itself. Actually this is a feature which quite a lot of our customers are using when they want their grid to be ajax bound only. Calling preventDefault the first time the OnDataBinding client event is raised would prevent this behavior:

var firstTime = true;

function onDataBinding(e) {
    if (firstTime) {
       e.preventDefault();
       firstTime = false;
    }
}

Regards,
Atanas Korchev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now.
Tags
Grid
Asked by
David
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
David
Top achievements
Rank 1
Share this question
or