posts - 64, comments - 387, trackbacks - 4

Paging with Filters and Sorts added to Unifico

Two new additions were added to Unifico: filtering on fields and sorting on fields with the help of Html Extension methods.

A PagingSet class was defined to contain configuration options for the paging. In this way a View can still page on more than one list and maintain complete control over the Html rendered. Every string used in the Html Helpers is pulled from the configuration (A default is made available).

Several extension methods were added to the Html Helper to make rendering the controls easier.

The filtering html form can be rendered with <%= Html.FilterInput(Paging, "Go") %> Where "go" is the button text.

A sortable column header can be rendered with <%= Html.PageSorting(Paging, "Email","E-Mail")%>

Where the paging configuration has been passed from the controller, leaving the paging control completely in the hands of the controller:

<% PageResponse<User> Users = (PageResponse<User>)ViewData.Model;

PagingSet Paging = (PagingSet)ViewData["PagingSet"];

%>

View the complete "View" here, http://www.codeplex.com/unifico/SourceControl/changeset/view/1798#54414

View the complete Controller here, http://www.codeplex.com/unifico/SourceControl/changeset/view/1798#44699

The end result of all this is paging that executes through the PageRequest class, so that no changes are required of the Service and paging that executes in SQL. It also has the nice benefit of residing completely in the QueryString and not requiring changes to the Controller's Action's parameters.

An example path created from paging with sorting and filtering: /Admin/Account/Users?expr=asdf9&filterby=All&orderby=Name&asc=False&page=1

And the SQL it generates.

exec sp_executesql N'SELECT TOP (10) [t0].[UserID] AS [ID], [t0].[Name], [t0].[Password], [t0].[Email]
FROM [dbo].[User] AS [t0]
WHERE ([t0].[Name] = @p0) OR ([t0].[Name] = @p1)
ORDER BY [t0].[Name] DESC',N'@p0 nvarchar(5),@p1 nvarchar(5)',@p0=N'asdf9',@p1=N'asdf9'

Print | posted on Sunday, January 04, 2009 6:25 PM | Filed Under [ Web Programming ]

Feedback

Gravatar

# re: Paging with Filters and Sorts added to Unifico

Hey I got the latest on your Unifico solution, and you seem to have forgotten to check in the PageSet class. I also checked on Codeplex under the Paging folder, and it wasn't there.
1/5/2009 1:19 PM | Khalid Abuhakmeh
Gravatar

# re: Paging with Filters and Sorts added to Unifico

Added, my apologies!

http://www.codeplex.com/unifico/SourceControl/changeset/view/1945#60446
1/5/2009 1:37 PM | Charles
Gravatar

# re: Paging with Filters and Sorts added to Unifico

Well it's a good start to an application, but there are a few things you should look at. First is your use of IoC, it's good that you are using it, but I don't think you are using it correctly.

public AccountAdminController()
{
accountService = ObjectFactory.GetInstance<IAccountService>();
}

Your constructor should look something like this

public AccountAdminController(IAccountService accountService)
{
_accountService = accountService;
}
This way anytime an AccountAdminController is created, the user is forced to pass that AccountService in. Rob Conery wrote a controllerfactory for MVC, check it out.

Also you could drastically reduce your ExpressionHelper class by using some reflection. You won't have those large if statements.

Also use IList<T> instead of List<T> (more loosely coupled).

Those are the first things I saw, but it is a pretty decent start. Hope that helps. Check out my blog too :)
1/5/2009 4:01 PM | Khalid Abuhakmeh
Gravatar

# re: Paging with Filters and Sorts added to Unifico

Thank you Khalid.

I think you might be right on the IoC. I will have to check out Rob’s controllerfactory. I agree on IList and will make that change.

With regard to the reflection, I am afraid to over use it for performance reasons. My thought is it’s faster to do a comparison than reflection. Though a large condition set may look bad, it should outperform? I did find a few ways to clean it up which need to be added as well.

You have been added to my feed :)

1/5/2009 10:29 PM | Charles
Gravatar

# re: Paging with Filters and Sorts added to Unifico

feed reader*
1/5/2009 10:31 PM | Charles
Gravatar

# re: Paging with Filters and Sorts added to Unifico

I couldn't get the Indian out of my head. Only a short time previously the Cherokees -- or was it the Camanches? -- had been removed from their hunting-grounds in Arkansas;

and in the wilds of the Southwest the red men were still a source of terror to the border settlers. "Trouble with the Indians" was the staple news from Florida published in the

New Orleans papers. We were constantly hearing of travellers being attacked and murdered in the interior of that State. If these things were done in Florida, why not in

Massachusetts?
12/30/2011 1:33 AM | Karen millen
Gravatar

# Aldo Wisenbaker

wedding dress 2011 ball gowns evening dresses mermaid wedding dress black evening dresses wedding dresses evening dresses plus size ball gowns evening dresses evening dress uk sexy wedding dress sexy wedding dress
1/10/2012 11:12 PM | column wedding dress
Gravatar

# re: Paging with Filters and Sorts added to Unifico

Hand-organs, drums, and trumpets, roared against each other; Bajazzo growled; a couple of hoarse girls sang and&nbsp;Karen millen outlet&nbsp; twanged upon the guitar: it was comic or affecting, just as one

was disposed. The evening approached, and now the crowd became greater, the joy more noisy.

"But where is Otto?" inquired Wilhelm. Otto had vanished in the crowd. Search after him would help nothing, chance must bring them together again. Had he designedly withdrawn

himself? no one knew wherefore, no one could dream what had passed within his soul. It became evening. The highway and the foot-path before the park resembled two moving gay

ribbons.

In the park itself the crowd perceptibly diminished. It was now the high-road which was become the Park-hill. The carriages dashed by each other as at a race; the people shouted

and sung, if not as melodiously as the barcarole of the fisher men below Lido, still with the thorough carnival joy of the south. The steamboat moved along the coasts. From the

gardens surrounding the pretty country-houses arose rockets into the blue sky, the Moccoli of the north above the Carnival of the Park.
2/1/2012 10:37 PM | Karenmillen

Post Comment

Title  
Name  
Email
Url
Comment   
Please add 8 and 4 and type the answer here:

Powered by:
Powered By Subtext Powered By ASP.NET