Kurkula
Kurkula

Reputation: 6762

mvc webgrid ajax paging

@{ 
    var gridUser = new WebGrid(canPage: true, defaultSort: "CreatedOn", rowsPerPage: 5, 
                            ajaxUpdateContainerId: "Divxyz"); 
    gridUser.Bind(Model.abc, rowCount: Model.User.Count(), autoSortAndPage: true); 
    gridUser.Pager(WebGridPagerModes.All); 

} 
<div id="Divxyz" style="display: none">

I am using a mvc3 webgrid with ajax paging ... I figured out my solution to do ajax Paging as above.

BUT ..... My grid is at bottom of the page and When I click on page number(It shows # as its linking page), it takes me to top of page moving grid to bottom of page again for every page number click. Please help me on this.

Thanks In Advance .

Upvotes: 0

Views: 2081

Answers (1)

Kurkula
Kurkula

Reputation: 6762

I figured out the solution for the issue. I added below script and when I click on page number page doesnt scroll

<script type="text/javascript">
    $(function () {
        $('th a, tfoot a').live('click', function () {
            $(this).attr('href', '#DivGridUser-anchor');
        });

    });
</script>

Upvotes: 2

Related Questions