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

[Solved] Server Binding with Ajax Calls

1 Answer 92 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.
madmike210
Top achievements
Rank 1
madmike210 asked on 14 Jul 2011, 07:50 PM
I am currently server binding my grid.  Does anyone know how can I use ajax calls when paging or sorting?

What I am trying to do is make ajax calls to the server to update the grid's div in with the new response results from the server.  I would like to prevent the entire page from refreshing when the user is interacting with the grid.

I don't want to use Ajax binding because I need to uses complex templates for my columns, so what I am doing doesn't work in ClientTemplates.

1 Answer, 1 is accepted

Sort by
0
madmike210
Top achievements
Rank 1
answered on 14 Jul 2011, 09:15 PM
I achieved what I wanted using jQuery to override the paging and sorting anchors.  These anchors have a class name of "t-link".  You can reference the anchors in your Grid by using the id of the Div that is holding the Grid.  I did this with jQuery by inserting the following code into the partial view that creates my Grid, where "GridResults" is the id of the div with my telerik grid:

<script type="text/javascript">
    $(document).ready(function () {
        $("div#GridResults a.t-link").click(function (e) {
            e.preventDefault();
            $("div#GridResults").css("cursor", "wait");
            $("div#GridResults a.t-link").css("cursor", "wait");
            var dest = $(this).attr("href");
            $.ajax({ url: dest,
                success: function (result) { $("#GridResults").html(result); },
                complete: function () {$("div#GridResults").css("cursor", "default"); $("div#GridResults a.t-link").css("cursor", "pointer");
                }
            });
        });
    });
</script>

If there is an easier way of doing this using telerik, please let me know.
Tags
Grid
Asked by
madmike210
Top achievements
Rank 1
Answers by
madmike210
Top achievements
Rank 1
Share this question
or