vtfuture / BForms

Bootstrap Forms for ASP.NET MVC
MIT License
62 stars 33 forks source link

Pagination #239

Closed meister-d closed 9 years ago

meister-d commented 9 years ago

Where can I configure the Default value of Items per Page (in the Grid control)? I would like to have 15 Items per Page. I tried allmost every where, in code behind, in Razor but no Chance. Can you please also Update it in the Docs if its possible ?

Regards Dumitru

cristipufu commented 9 years ago

If you're using the abstract class BsBaseGridRepository<TEntity, TRow> first of all you have to specify the PageSize property of the BsGridRepositorySettings<TSearch>:

var settings = new BsGridRepositorySettings<ContributorSearchModel>()
{
       PageSize = 15,
       Page = 1
};
var gridModel = _gridRepository.ToBsGridViewModel(settings , x => x.Id);

That's how you'll set the number of rows to be retrieved from the database.

Second, you have to change the grid pager rendering settings and include your custom value to the PageSizeValues property:

@Html.BsGridFor(m => m.Grid)
 PagerSettings(new BsPagerSettings 
{
        PageSizeValues = new List<int> { 5, 15, 20, 25, 50 }
})

If you still have any problems, please let me know and show me your code (controller, view)

meister-d commented 9 years ago

Thanx Cristi, like this it works for me.