Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9202663
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:18:33+00:00 2026-06-17T23:18:33+00:00

I create an application using asp mvc razor + mvc grid. My problem is

  • 0

I create an application using asp mvc razor + mvc grid.
My problem is : i have one view that contain multiple action that return partial view, in each partial view there is a grid that display the data. I am using mvc contrib grid which support paging and sorting.

My view (index.cshtml) :

<div class="row-fluid">
    <div id="formations" class="control-group">
    @Html.Action("Formations")
</div>

<div id="pools" class="control-group">
    @Html.Action("Pools")
</div>

<div id="zones" class="control-group">
    @Html.Action("Zones")
</div>

Formations action :

    public ActionResult Formations(GridSortOptions sort, int? page, string filter = "all")
    {

        IPagination<StratUnitVo> pagination = ....        
        return PartialView("_Formations", pagination);
    }

Partial View _Formations :

@Html.Grid(Model).Sort(ViewData["sort"] as GridSortOptions).Columns(col =>
  {
       col.For(p => Html.ActionLink(p.LongName, "EditFormation", "Stratigraphy", new { id = p.Id }, null).ToHtmlString()).Encode(false).Named(Locale.Name).SortColumnName("LongName");
       col.For(p => p.FormCode).Named(Locale.Code);
   col.For(p => p.ReferenceStratUnit.LongName).Named(Locale.ReferenceFormation);      
   }).Attributes(@class => "table table-condensed table-striped table-hover")

@if (Model.Count() > 0)
{
    @Html.Raw(@Html.Pager(Model)));
}

Other action and view is most like sample above (just difference in the model data).
My problem is :

  1. When i click the navigation paging in one grid (example : Formations), the other grid (Pools and Zones) will be navigate to. For example : click page 2 in formations grid will move another grid to page 2 too.
  2. When i click the column header in one grid (which mean i want to sort the data), the whole page is replaced by partial view. What i want is only the grid that i have clicked is sorted.

How can i fix that ?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T23:18:35+00:00Added an answer on June 17, 2026 at 11:18 pm

    Well, I just solved my problem like this :

    1. For paging : add new parameter for each action called ‘type’ and validate based on the parameter.

      public ActionResult Formations(GridSortOptions sort, int? page, string type, string filter = "all")
      {
          if (type != null && !type.Equals("Formation")) page = 1;            
      
          IPagination<StratUnitVo> pagination = ......
          return PartialView("_Formations", pagination);
      }
      
    2. For sorting : use ajax sort for mvc grid :

      $(function () {
          ajaxSort('pools', 'Stratigraphy', 'Pools');
          ajaxSort('formations', 'Stratigraphy', 'Formations');
          ajaxSort('zones', 'Stratigraphy', 'Zones');         
      });
      
      function ajaxSort(tableId, controllerName, actionName) {
      $(document).on('click', '#' + tableId + ' > table > thead > tr > th > a', (function () {
      // store the href attribute, will get the column and direction parameter
      var href = $(this).attr('href');
      
      // mvc grid sort url is : 'http\\controllerName\\actionName?Column=columnname&Direction=[Ascending|Descending]            
      var temp = href.split('&');
      
      // retrieve the column name
      var column = temp[0].split('=')[1];
      // retrieve sort direction
      var direction = temp[1].split('=')[1];
      // retrieve column header
      var columnHeader = $(this).text();
      
      // remove the href attribute, prevent postback
      $(this).removeAttr('href');
      
      // use ajax to sort
      $.ajax({
          url: '/' + controllerName + '/' + actionName,
          data: { 'Column': column, 'Direction': direction },
          dataType: 'html',
          success: function (data) {                
              $('#' + tableId).html(data);
      
              columnHeader = columnHeader.replace('\u25B2', '').replace('\u25BC', '');
      
              // show up down arrow
              // \u25B2 and \u+25BC is the unicode character for up/down triangle (arrow) to display in HTML                                
              var column = $('#' + tableId + ' > table > thead > tr > th > a:contains(' + columnHeader + ')');
      
              if(direction == 'Ascending')
                  column.text(columnHeader + "\u25B2");
              else {                
                  column.text(columnHeader + "\u25BC");
              }
          },
         });
        }));
      }
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have web application that are using multiple clients. I should create one copy
I have developed a web application using ASP.Net MVC 4, then hosted that web
I am developing an ASP.Net MVC 3 Web Application. I have a Razor View
Here's the situation: ASP.NET MVC 3 application using Razor as the view engine. Works
I have created a sample project using ASP.NET MVC 3 Web Application (Razor) template.
I need to create a web application using ASP.NET MVC, jQuery and web standards
I am using FckEditor in Create.aspx page in asp.net mvc application. Since I need
I am using asp.net .. i have created one small application.. I have Configure
I am creating an application using asp.net MVC. By default, the model, view and
If I create an ASP.NET MVC 4 Web Application using the Internet Application template,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.