-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added PageNumberTemplate and capabilities in DataPager control
- Loading branch information
1 parent
8c433d6
commit 67b4d47
Showing
6 changed files
with
222 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/Samples/Common/ViewModels/ControlSamples/DataPager/DataPagerTemplatesViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using DotVVM.Framework.Controls; | ||
using DotVVM.Framework.ViewModel; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace DotVVM.Samples.BasicSamples.ViewModels.ControlSamples.DataPager | ||
{ | ||
public class DataPagerTemplatesViewModel : DotvvmViewModelBase | ||
{ | ||
public GridViewDataSet<Data> DataSet { get; set; } | ||
|
||
public string[] RomanNumerals { get; set; } = new[] { "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X", "XI", "XII", "XIII", "XIV", "XV", "XVI", "XVII", "XVIII", "XIX", "XX" }; | ||
|
||
public override Task Init() | ||
{ | ||
DataSet = new GridViewDataSet<Data>() | ||
{ | ||
PagingOptions = new PagingOptions() | ||
{ | ||
PageSize = 3 | ||
} | ||
}; | ||
return base.Init(); | ||
} | ||
|
||
public override Task PreRender() | ||
{ | ||
if (DataSet.IsRefreshRequired) | ||
{ | ||
DataSet.LoadFromQueryable(FakeDB(50)); | ||
} | ||
|
||
return base.PreRender(); | ||
} | ||
|
||
private IQueryable<Data> FakeDB(int itemsCreatorCounter) | ||
{ | ||
var dbdata = new List<Data>(); | ||
for (var i = 0; i < itemsCreatorCounter; i++) | ||
{ | ||
dbdata.Add(new Data | ||
{ | ||
Text = $"Item {i}" | ||
}); | ||
} | ||
return dbdata.AsQueryable(); | ||
} | ||
|
||
public class Data | ||
{ | ||
public string Text { get; set; } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/Samples/Common/Views/ControlSamples/DataPager/DataPagerTemplates.dothtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
@viewModel DotVVM.Samples.BasicSamples.ViewModels.ControlSamples.DataPager.DataPagerTemplatesViewModel, DotVVM.Samples.Common | ||
|
||
<!DOCTYPE html> | ||
|
||
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title></title> | ||
<style> | ||
.pagination { | ||
list-style-type: none; | ||
display: flex; | ||
align-items: center; | ||
} | ||
.page-item { | ||
margin: 0 1em; | ||
} | ||
.page-link { | ||
text-decoration: none; | ||
} | ||
.disabled { | ||
opacity: 0.3; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
|
||
<h1>Templates in DataPager</h1> | ||
|
||
<dot:Repeater DataSource="{value: DataSet}" WrapperTagName="ul"> | ||
<ItemTemplate> | ||
<li>{{value: Text}}</li> | ||
</ItemTemplate> | ||
</dot:Repeater> | ||
|
||
<dot:DataPager DataSet="{value: DataSet}" | ||
class="pagination" | ||
ListItemclass="page-item" | ||
Linkclass="page-link"> | ||
<FirstPageTemplate>◀️◀️</FirstPageTemplate> | ||
<PreviousPageTemplate>◀️</PreviousPageTemplate> | ||
<NextPageTemplate>▶️</NextPageTemplate> | ||
<LastPageTemplate>▶️▶️</LastPageTemplate> | ||
<PageNumberTemplate> | ||
{{value: _root.RomanNumerals[_this]}} | ||
</PageNumberTemplate> | ||
</dot:DataPager> | ||
|
||
</body> | ||
</html> | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters