Can't Paging Support be simplify

Can't Paging Support be simplify

Old forum URL: forums.lhotka.net/forums/t/2261.aspx


kids_pro posted on Friday, February 02, 2007

I wonder wy paging support such a burden issue?
Can we just grap all the data from the data store and pass it to CslaDataSource then CslaDataSource deal with the UI which part of data it need to past back to the UI base on the PageIndex.

PersonList list = PersonList.GetPersonList(); // return 20 records
e.BusinessObject = list; //

And if these block of could exist:

int totalRow = e.BusinessObject.TotalRow; // would return 20
e.BusinessObject.PageSize = 10;
e.BusinessObject.PageIndex = 0;

Let see if we want to know how many records do list.Count.
I think it is the CslaDataSource problem to deal with the UI the BO code shouldn't have to deal with these thing.

ballistic replied on Friday, February 02, 2007

I believe that the reason the BO needs to be involved is so that it knows how  many records it should pull.

I am assuming that 20 records are ALL records, but are only displaying 10 of them (the other 10 get returned, but are not displayed).  By involving the BO, you are telling it how many can be displayed and only returns those (10) while populating the count (20) to allow for the paging.

Basically, it needs to know how many are going to be displayed so it can only return those, otherwise it returns all records and depends on the GUI to display what it can and the remaining are wasted.

Please correctly if I'm wrong.

kids_pro replied on Friday, February 02, 2007

Yes, what you believe is true and I think that what rocky had in mind.
In some situation I might want to load 2 pages to reduce round trip to server, that not possible now.

But anyway now I am clear and prepare to live with it well :)

RockfordLhotka replied on Friday, February 02, 2007

You do have a lot of flexibility here.

If you are willing to store the full data set in memory in the web server (in Session or System.Web.Caching or something) then you absolutely could write your code to retrieve the full set of data on the first call and then only return a page at a time. That model would be quite different from what I show in the 2.1 Handbook, but it would be relatively easy to do.

But I think most people use paging to avoid bringing all the data back from the database, and so that's the approach I show in the 2.1 Handbook.

cmellon replied on Sunday, February 04, 2007

If you use some of the commercial grids available, I think you can jsut bind a full list of data to them and they will handle all the pagin stuff for you.

I have done this with relatively small lists (100 or less records), and just fill a collection, and my grid handles the paging, I just click the Enable Paging option, simple as that.

I use telerik controls for web stuff, and infragistics for winforms.  Not sure about infragistics, but telerik seems to hanlde the paging itself.

kids_pro replied on Sunday, February 04, 2007

Yes, that my point.
Paging is UI responsibility since CslaDataSource is the one component that deal with UI we should force responsibility upon it.

RockfordLhotka replied on Sunday, February 04, 2007

Oh I see, you want CslaDataSource to keep a copy of the complete collection and return only a subset of that collection on demand?

 

That would be difficult (though not impossible) with the CSLA .NET data portal model. You’d still have to do some extra work in your business collection class, because this scheme would require that the collection be created via DP_Fetch(), but that object would never be publicly exposed. Rather, there’d need to be some new mechanism by which CslaDataSource could create new instances of your collection class, and indicate that you should load that new instance with just one page of data from the existing complete list.

 

Again, in the web model the typical idea behind paging is to avoid loading all the data from the database in one shot – which this would require – so I’m not convinced that it is a good idea, or one that most people would even consider using.

 

Rocky

 

From: kids_pro [mailto:cslanet@lhotka.net]
Sent: Sunday, February 04, 2007 7:21 PM
To: rocky@lhotka.net
Subject: Re: [CSLA .NET] Can't Paging Support be simplify

 

Yes, that my point.
Paging is UI responsibility since CslaDataSource is the one component that deal with UI we should force responsibility upon it.


Copyright (c) Marimer LLC