Performance issue in MVC Grid

Nov 6, 2014 at 3:53 PM

i implemented your grid was ossam..

the problem when i tried to load the bulk data,its taking too time to load the data to gridview.

so is it possible to load the data pagewise...instead of loading all the data at one shot,can we load the data page it possible..

i dont want the ajax scroll down paging..because this current grid was already shown to client

please help me..already we deployed to we are facing performance issue
May 29, 2015 at 8:09 PM

I'm experiencing the same problem!

I also dont want the ajax scroll down paging because this current grid was already shown to client.

Could someone help me?

Jun 1, 2015 at 3:54 PM

Still waiting for some help!!!

Jul 6, 2015 at 7:12 PM
Hi all,

Could someone please help me with this? I'm more than a month with this problem, please!
Jul 7, 2015 at 2:54 PM
Maybe you are putting all your data in memory first and only then giving it to the grid?
Could you show your code from the controller and the view?
Sep 2, 2015 at 1:26 PM
Dear all,

well I've programmed generic expressions which I use in EF6 for filtering the data. Now the data is filtered on SQL - Server.

Kind regards,
Sep 10, 2015 at 6:22 PM
Hi, Leyla..

This my code from the controller:
public ActionResult Index()
    List<PerfilViewModel> lstPerfil = new List<PerfilViewModel>();
    List<PerfilDescricao> DBPerfis;

        DBPerfis = ((IPerfilDescricaoBusiness)BusPerfil).GetPefisDescricoes();
        foreach (var item in DBPerfis)
            lstPerfil.Add(new PerfilViewModel { Id = item.Id, Descricao = item.Descricao, TipoPerfil = item.DescricaoTipoPerfil });
    catch(Exception ex)
    return View(lstPerfil);
And this is my code from the view:
@Html.Grid(Model).Named("gridUsuarioEmpresa").Columns(columns =>
    columns.Add(c => c.Selected).Encoded(false).Sanitized(false).SetWidth(30).Titled("").RenderValueAs(c => Html.CheckBox("checkbox_" + c.Id.ToString(), c.Selected));
    columns.Add(c => c.Ativa, true);
    columns.Add(c => c.Id, true).SetFilterWidgetType("System.String");
    columns.Add(c => c.CNPJ).Titled(@Resource.LBLUCCOLUMNCNPJ).SetFilterWidgetType("System.String");
    columns.Add(c => c.RazaoSocial).Titled(@Resource.LBLUCCOLUMNRAZAOSOCIAL).SetFilterWidgetType("System.String");
}).Selectable(true).Filterable(true).Sortable(true).WithPaging(15, 5)
It's loading all the data at one shot for each page selected and then only shows the fifteen corresponding to that page. Basically, the performance problem is the time the browser takes to receive the entire amount of data and only then pick up fifteen records corresponding to that page. The ideal was the browser receive only the fifteen records corresponding to that page.
Sep 22, 2015 at 5:09 AM
Grid would do that, but you yourself are creating a list of all elements in a controller with this lstPerfil.Add statement.
Sep 22, 2015 at 5:22 PM
Edited Sep 22, 2015 at 5:23 PM
I'm gonna check and reply you in a moment. But do you think that this is the problem?
Sep 24, 2015 at 5:49 PM
Yes I definitely think so
Sep 25, 2015 at 4:48 AM
Leya wrote:
Grid would do that, but you yourself are creating a list of all elements in a controller with this lstPerfil.Add statement.
Yes, we can just load one page of data from the database in controller, but the GridMVC's paging will not working, because it cannot get the total records from the model object. And the fields filtering also won't work, it just filter data in model and render them. So the filtering won't return the data what you want.
Sep 25, 2015 at 7:56 AM
extends Grid<T>, and extends GridPager, then new your own Grid object in controller and pass one page data and total data amount to custom GridPager.
Oct 20, 2015 at 5:29 PM
Hi, Leya and flysocket!

Sorry for the delay.

Leya, i didn't understand your point. One of the constructors receive a list of models. The "Model" variable represents a IEnumerable<SupplierFinance.UI.WebSite.Models.PerfilViewModel>. I don't know how to fix this 'problem".

flysocket, could you please show me some code that explains what you are saying? Thanks in advance.
Oct 20, 2015 at 7:28 PM

I dont know why you said that "Grid would do that, but you yourself are creating a list of all elements in a controller with this lstPerfil.Add statement", but the code "WithPaging(15, 5)" works as expected. Only 15 registers per page and with 5 buttons for pagination.

All the filters and the sorting works great in my current scenario. The problem is that for every page it renders all content and not only the part corresponding to the chosen page (in my case, 15 registers). Whe you see the time for response in the browser, it's too high.
Nov 20, 2015 at 12:33 PM
Leya? flysocket? Someone?
Nov 29, 2015 at 6:48 PM
Nov 29, 2015 at 7:33 PM
As Leya says, you are loading the data by yourself,
  1. Use EF
  2. Create A DbContext
  3. Declare your query in lambda expression
  4. pass the query to View as IQueryable<SupplierFinance.UI.WebSite.Models.PerfilViewModel>
Don't use foreach or IEnumerable (Or List) that will kill your grid.

Your controller need to look like this:
var ctx = new DbContext()
var query = ctx.Perfil.Where(m => == "a")
return View(query.Select(x =>
    new SupplierFinance.UI.WebSite.Models.PerfilViewModel {
                    a = x.a,
                    b = x.b
Apr 11 at 6:34 AM
Edited Apr 11 at 6:35 AM
Hi all,

Same issue we are also facing...

Scenario is:
Let say we have 10,000 records in a database table and infront end grid page size is 10,
then page nation is created with 1000 pages(10000/10). Whenever the user clicks particular page let say page 2 then request is going to DB and fetching all the 10,000 records on top of it next 10 records are getting picked and display.

Here my concern is to fetch next 10 records only instead 10,000 records for every pagination click or Initial load.

Can anyone help on this.... ?