setting ItemsCount and paging is not working for me. please help.

Oct 29, 2012 at 5:27 PM

this is a great project. thank you very much for sharing.

current issue I'm having is having too much data pulled from the database just to feed into the Grid<T>.

I try to implement on top of this by pulling just enough data for that page and feed in the total number of items and let it do the paging. ie, I have Pager.PageSize = 20; Pager.ItemsCount = 500; EnablePaging = true;

pass in the data for the 1st page, 20 items.

I can't seem to have it populate the paging.  if i set the Pager.PageSize = 10, then i get 2 paging.  so I guessing my Pager.ItemsCount setter doesn't do anything.  

my thought would be, passing in the total ItemsCount, set the pagesize, with the currentPage, and passing in the data would populate the correct paging without having to pull the whole collection from the database everytime.

Please let me know if there is a better implementation for this.

Thank you very much.

Coordinator
Oct 29, 2012 at 6:04 PM

Hi, thanks.

Yes, that's it. The Grid automatically determines items count of the source collection at render time. This need that you can use the built-in functionallity, like filtering and Grid needs to count this customized collection.

If you use Entity Framework in your project - you can pass IQueryable collection to the Grid and he will make only 2 queries to your database:

1. Query selected page of data,

2. Query COUNT of source collection (filtered if need)

In this case Grid.Mvc do not pull much data from database. You can check it with SQL Profilier.

In other custom case you can disable paging in the Grid (EnablePaging = false) and render Grid and Pager separately:

@Html.Partial("_Grid", Model.Grid)
@Html.Partial("_GridPager", Model.Pager)
Where Model.Pager - derives from GridMvc.Pagination.IGridPager (you can use default implemetation - GridMvc.Pagination.GridPager).

Oct 29, 2012 at 6:22 PM

wow. That's a very fast respond.  Thank you very much.  I'm trying this now.

Oct 30, 2012 at 5:06 PM

in this project I'm using RavenDb (NoSQL database) so I built a way to work around it using pager partial view.

I still have one issue with search filter and case sensitive.  data returned fine without case sensitive using service but gridMvc automatically filter out the case sensitive items (especially contains operation).  I can't seems to find an option for this, is there an option for it or I have to look into the code to find out where?  I don't think this is filter via JavaScript since i can't see the filtered items in view page source.

Coordinator
Oct 30, 2012 at 6:04 PM

Thank's for reporting issue. It appears on the LINQ to objects, because GridMvc builds filter expression like:

e=>e.Property.Contains(value);

It's ok for EF context, because it build SQL query using LIKE operator: Field LIKE '%value%'

For resolving this issue GridMvc must build expression like:

e=>e.Property.ToUpper().Contains(value.ToUpper());

I will fix this problem in the next release of Grid.Mvc about a few days.

Oct 30, 2012 at 8:42 PM

Thank you very much Bukharin.  Looking forward it.

Coordinator
Oct 31, 2012 at 1:48 PM

It's done. You can updates to 2.1.0 version.

Oct 31, 2012 at 3:21 PM

wow that's fast.  thank you very much.

I got a chance to look into the code and see how you wiring it up.  amazing.

not sure if you like to implement more filter operation (such as not equal, not start with, multiple filter etc) or not but if you do, I found the project below very helpful to it.  it pretty much do the same thing you did with reflection to find column property and create expression for where clause.  the one thing that I like is the Filter Operation Attribute.  David has a smart design of creating an attribute for the enum filter operation and then use it when generating the expression for where clause, in this case we don't have to loop through each case and when we add a new operation option, we simply add in enum with attribute without adding another case.

hope this help to make this project bigger.

https://github.com/DavidHoerster/ExpressionSearch

Coordinator
Oct 31, 2012 at 4:05 PM

Thank's. I'll look at this project

Nov 2, 2012 at 4:23 PM

Hi Bukharin,  

thank you very much for the quick fix.  

contains is now fixed with non case sensitive but Equals, StartsWith, and EndsWith is still using case sensitive.  from a user POV, they wouldn't care of know which case they should be using.  

are there any chance you can change this or add in option for case sensitive in future releases? or maybe add an option for display everything provided without filtering?  

thank you very much.

Coordinator
Nov 6, 2012 at 11:11 AM

Hi, I forgot for other filter types.

I updated the grid to 2.1.5 version to solve this issue You can update it.