Skip to content

Commit

Permalink
Fix DataPager.RenderLinkForCurrentPage
Browse files Browse the repository at this point in the history
  • Loading branch information
exyi authored and tomasherceg committed Nov 11, 2023
1 parent 506d801 commit 8dcf71f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 12 deletions.
12 changes: 10 additions & 2 deletions src/Framework/Framework/Controls/DataPager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,18 @@ protected virtual void DataBind(Hosting.IDotvvmRequestContext context)
// li.SetBinding(DataContextProperty, GetNearIndexesBinding(context, i, dataContextType));
liTemplate.CssClasses.Add(ActiveItemCssClass, new ValueOrBinding<bool>(pagerBindings.IsActivePage.NotNull()));
var link = new LinkButton();
link.SetBinding(ButtonBase.ClickProperty, pagerBindings.GoToPage!);
link.SetBinding(ButtonBase.TextProperty, pagerBindings.PageNumberText);
link.SetBinding(ButtonBase.ClickProperty, pagerBindings.GoToPage.NotNull());
link.SetBinding(ButtonBase.TextProperty, pagerBindings.PageNumberText.NotNull());
if (!true.Equals(enabled)) link.SetValue(LinkButton.EnabledProperty, enabled);
liTemplate.Children.Add(link);
if (!this.RenderLinkForCurrentPage)
{
var notLink = new Literal(pagerBindings.PageNumberText);
notLink.RenderSpanElement = true;
notLink.SetBinding(DotvvmControl.IncludeInPageProperty, pagerBindings.IsActivePage);
link.SetBinding(DotvvmControl.IncludeInPageProperty, pagerBindings.IsActivePage.Negate());
liTemplate.Children.Add(notLink);
}
NumberButtonsRepeater = new Repeater() {
DataSource = pagerBindings.PageNumbers,
RenderWrapperTag = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public override Task PreRender()
}

[AllowStaticCommand]
public async Task<GridViewDataSet<CustomerData>> LoadStandard(GridViewDataSetOptions options)
public static async Task<GridViewDataSet<CustomerData>> LoadStandard(GridViewDataSetOptions options)
{
var dataSet = new GridViewDataSet<CustomerData>();
dataSet.ApplyOptions(options);
Expand All @@ -64,7 +64,7 @@ public async Task<GridViewDataSet<CustomerData>> LoadStandard(GridViewDataSetOpt
}

[AllowStaticCommand]
public async Task<NextTokenGridViewDataSet> LoadToken(GridViewDataSetOptions<NoFilteringOptions, SortingOptions, CustomerDataNextTokenPagingOptions> options)
public static async Task<NextTokenGridViewDataSet> LoadToken(GridViewDataSetOptions<NoFilteringOptions, SortingOptions, CustomerDataNextTokenPagingOptions> options)
{
var dataSet = new NextTokenGridViewDataSet();
dataSet.ApplyOptions(options);
Expand All @@ -73,7 +73,7 @@ public async Task<NextTokenGridViewDataSet> LoadToken(GridViewDataSetOptions<NoF
}

[AllowStaticCommand]
public async Task<NextTokenHistoryGridViewDataSet> LoadTokenHistory(GridViewDataSetOptions<NoFilteringOptions, SortingOptions, CustomerDataNextTokenHistoryPagingOptions> options)
public static async Task<NextTokenHistoryGridViewDataSet> LoadTokenHistory(GridViewDataSetOptions<NoFilteringOptions, SortingOptions, CustomerDataNextTokenHistoryPagingOptions> options)
{
var dataSet = new NextTokenHistoryGridViewDataSet();
dataSet.ApplyOptions(options);
Expand All @@ -82,7 +82,7 @@ public async Task<NextTokenHistoryGridViewDataSet> LoadTokenHistory(GridViewData
}

[AllowStaticCommand]
public async Task<MultiSortGridViewDataSet> LoadMultiSort(GridViewDataSetOptions<NoFilteringOptions, MultiCriteriaSortingOptions, PagingOptions> options)
public static async Task<MultiSortGridViewDataSet> LoadMultiSort(GridViewDataSetOptions<NoFilteringOptions, MultiCriteriaSortingOptions, PagingOptions> options)
{
var dataSet = new MultiSortGridViewDataSet();
dataSet.ApplyOptions(options);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<dot:GridViewTextColumn HeaderText="Message Received" ValueBinding="{value: MessageReceived}" AllowSorting="True" />
</Columns>
</dot:GridView>
<dot:DataPager DataSet="{value: StandardDataSet}" LoadData="{staticCommand: _root.LoadStandard}" />
<dot:DataPager DataSet="{value: StandardDataSet}" LoadData="{staticCommand: RootViewModel.LoadStandard}" />
<%--
<h1>NextToken paging options</h1>
<dot:GridView DataSource="{value: NextTokenDataSet}"
Expand All @@ -31,11 +31,11 @@
<dot:GridViewTextColumn HeaderText="Message Received" ValueBinding="{value: MessageReceived}" />
</Columns>
</dot:GridView>
<dot:DataPager DataSet="{value: NextTokenDataSet}" LoadData="{staticCommand: _root.LoadToken}" />
<dot:DataPager DataSet="{value: NextTokenDataSet}" LoadData="{staticCommand: RootViewModel.LoadToken}" />

<h1>NextTokenHistory data set</h1>
<dot:GridView DataSource="{value: NextTokenHistoryDataSet}"
<%--LoadData="{staticCommand: _root.LoadTokenHistory}"--%>
<%--LoadData="{staticCommand: RootViewModel.LoadTokenHistory}"--%>
>
<Columns>
<dot:GridViewTextColumn HeaderText="Id" ValueBinding="{value: CustomerId}" />
Expand All @@ -44,11 +44,11 @@
<dot:GridViewTextColumn HeaderText="Message Received" ValueBinding="{value: MessageReceived}" />
</Columns>
</dot:GridView>
<dot:DataPager DataSet="{value: NextTokenHistoryDataSet}" LoadData="{staticCommand: _root.LoadTokenHistory}" />
<dot:DataPager DataSet="{value: NextTokenHistoryDataSet}" LoadData="{staticCommand: RootViewModel.LoadTokenHistory}" />

<h1>MultiSort data set</h1>
<dot:GridView DataSource="{value: MultiSortDataSet}"
<%--LoadData="{staticCommand: _root.LoadMultiSort}"--%>
<%--LoadData="{staticCommand: RootViewModel.LoadMultiSort}"--%>
>
<Columns>
<dot:GridViewTextColumn HeaderText="Id" ValueBinding="{value: CustomerId}" AllowSorting="True" />
Expand All @@ -57,7 +57,7 @@
<dot:GridViewTextColumn HeaderText="Message Received" ValueBinding="{value: MessageReceived}" AllowSorting="True" />
</Columns>
</dot:GridView>
<dot:DataPager DataSet="{value: MultiSortDataSet}" LoadData="{staticCommand: _root.LoadMultiSort}" />
<dot:DataPager DataSet="{value: MultiSortDataSet}" LoadData="{staticCommand: RootViewModel.LoadMultiSort}" />
--%>
</div>
</body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@
</li>
<!-- ko foreach: { data: Customers()?.PagingOptions()?.NearPageIndexes } -->
<li data-bind="css: { active: $data == $parent.Customers()?.PagingOptions()?.PageIndex() }">
<!-- ko if: $data != $parent.Customers()?.PagingOptions()?.PageIndex() -->
<a data-bind="text: $data + 1" href="javascript:;" onclick="dotvvm.postBack(this,[&quot;Customers()?.PagingOptions()?.NearPageIndexes/[$index]&quot;],&quot;3DH6e+4ylYjhk3T4&quot;,&quot;&quot;,null,[],[],undefined).catch(dotvvm.log.logPostBackScriptError);event.stopPropagation();return false;"></a>
<!-- /ko -->
<!-- ko if: $data == $parent.Customers()?.PagingOptions()?.PageIndex() -->
<span data-bind="text: $data + 1"></span>
<!-- /ko -->
</li>
<!-- /ko -->
<li data-bind="css: { disabled: Customers()?.PagingOptions()?.IsLastPage }">
Expand Down

0 comments on commit 8dcf71f

Please sign in to comment.