Pagination With Grid In Partial View

Jan 8, 2014 at 3:25 PM
When the grid is placed in a partial view the pagination breaks.

i.e. When going to page "2" ..the url is http://localhost:53088/?grid-page=2
Coordinator
Jan 9, 2014 at 2:47 AM
Hi,

Where the problem? In the demo grid placed in partialview, please see https://gridmvc.codeplex.com/SourceControl/latest#GridMvc/GridMvc.Site/Views/Home/_OrdersGrid.cshtml
Jan 24, 2014 at 7:22 PM
Hi ,


I am also getting same problem.

Scenario is :

I have a view and controller named ClientInfo and here client info is coming from DB by serach doing from view and

example

public ActionResult GetClientInfo()
    {
        ClientAccountViewModel model = new ClientAccountViewModel();   // binding  drop downs in model for search drop down
        return View(model);
    }
public ActionResult GetClientInfo(ClientAccountViewModel viewModel)
    {

        string SearchCriteria = viewModel.SearchCriteria;
        string SearchBy = viewModel.SearchBy;

        var data = objAccountService.GetClientInfo(SearchCriteria, SearchBy);
        ClientAccountViewModel modal = new ClientAccountViewModel()
                                        {
                                            FirstName = data.FirstName,
                                            Email = data.Email,
                                            Phone = data.Phone

                                        };

        return View(modal);
}


Now from same view I am calling a partial view "DisplayAccount" which show accounts related to an Client

@Html.Action("DisplayAccount", "ClientAccount", new { ClientID = Model.ClientId })

and Action method for this is
public ActionResult DisplayAccount(int ClientID)
{
// data in model
return PartialView(listAccountModel);
}

here I have made paging true by

.WithPaging(5)

all is working well except Paging when I clicked on next page
showing this

http://localhost:19901/ClientAccount/GetClientInfo?grid-page=2

with blank page

I have been stuck and have tried a lot

Pls help



Thanks
Sachin
Coordinator
Jan 25, 2014 at 4:26 AM
Hi

I can't reproduce the problem. I try to render grid in a separate action using Html.Action helper - paging works. I pushed me changes to the repository. Please see how I do that - https://gridmvc.codeplex.com/SourceControl/latest#GridMvc/GridMvc.Site/Views/Home/Index.cshtml

Which version of the grid are you using?
Jan 25, 2014 at 7:41 AM
Edited Jan 25, 2014 at 2:21 PM
Hi

I saw your demo url
but no help

Iam using
Version is 3

I have downloaded Grid.Mvc.3 from internet and all files are added in my project

this is the url when main view loads :
http://localhost:19901/ClientAccount/GetClientInfo
and shows a search functionality

and onclick of serach button this view again loads with serached data

and from this main view I am calling partial view by passing client Id and this brings account data of a client by this method :

@Html.Action("DisplayAccount", "ClientAccount", new { ClientID = Model.ClientId })

okay ?

public ActionResult DisplayAccount(int ClientID)
{
// listAccountModel = data in model from database
return PartialView(listAccountModel);
}


this is show in main view with grid added with rows ( all fine)

but when I click on page 2 of grid
it serach for url

http://localhost:19901/ClientAccount/GetClientInfo?grid-page=2

as for paging your anchor buttons are like this -
href="?grid-page=1"
href="?grid-page=2"

and it adds page url in front

and not call DisplayAccount action (I think it should)


so, where is the problem

do I need to call this function separately from view on click of page no 2
or should It do automatically

thanks
sachin
Jan 27, 2014 at 7:36 PM
No one knows answer for this . please reply ?
Is it due to search functionality on main view
then how should design this or code this ?


thanks
sachin
Coordinator
Jan 28, 2014 at 3:03 AM
Edited Jan 28, 2014 at 3:04 AM
Hi,

You need to understand why you app not available at /ClientAccount/GetClientInfo?grid-page=2 url. It seems an error occurs. Try to temporary remove public ActionResult GetClientInfo(ClientAccountViewModel viewModel) method (maybe MVC cannot select a route.

How your search form looks like? Which version of asp.net MVC are you using?