New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactoring of GridViewDataSet #1548
base: main
Are you sure you want to change the base?
Conversation
18b3058
to
2ca439b
Compare
ac3cf9a
to
8dcf71f
Compare
52a010c
to
65fe97f
Compare
d57ecbb
to
4c1f8c1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other significant unsolved problems are:
- The dataset translations will only work in the context of DataSetClientSideLoad, not in ad-hoc staticCommand
- Async LoadFromQueryable (and the IPagingOptionsLoadingPostProcessor interface), I will make a separate PR for that
@@ -125,6 +128,7 @@ | |||
<ItemGroup> | |||
<!-- the wildcard would not work in Target.Inputs, it only works in Include --> | |||
<TypescriptFile Include="Resources/Scripts/**/*.ts" /> | |||
<UpToDateCheckInput Include="Resources/Scripts/**/*.ts" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do these changes do?
writer.AddAttribute("onclick", KnockoutHelper.GenerateClientPostBackScript( | ||
nameof(Click), clickBinding, this, | ||
new PostbackScriptOptions(commandArgs: BindingHelper.GetParametrizedCommandArgs(this, ClickArguments))), | ||
append: true, appendSeparator: ";"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should consider moving the postback script generation to the base class, this is somewhat arcane if someone want to make a custom button
@@ -11,11 +9,11 @@ public interface IRefreshableGridViewDataSet : IBaseGridViewDataSet | |||
/// Gets whether the data should be refreshed. This property is set to true automatically | |||
/// when paging, sorting or other options change. | |||
/// </summary> | |||
bool IsRefreshRequired { get; } | |||
bool IsRefreshRequired { get; set; } | |||
|
|||
/// <summary> | |||
/// Requests to reload data into the <see cref="IRefreshableGridViewDataSet" />. | |||
/// </summary> | |||
void RequestRefresh(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this method if are adding the IsRefreshRequired setter?
I actually think it's more obvious what dataset.IsRefreshRequired = true
than dataset.RequestRefresh()
- it's clear that it's no magic request, just a boolean flag
public TRowEditOptions RowEditOptions { get; set; } | ||
|
||
|
||
IList IBaseGridViewDataSet.Items => Items is List<T> list ? list : Items.ToList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd either throw an exception or change the return type IReadonlyList
(or return a readonly list). E.g. deleting from the Items returned by this property might do nothing and I'd not want to debug this.
(dataSource as IPageableGridViewDataSet<IPagingFirstPageCapability>)?.PagingOptions.GoToFirstPage(); | ||
(dataSource as IRefreshableGridViewDataSet)?.RequestRefresh(); | ||
}), | ||
new IdBindingProperty($"{this.GetDotvvmUniqueId().GetValue()}_sortBinding") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We used to simply call the SortChanged
without the additional paging+refresh, why is this needed? Since we now have the Button CommandParameters, we wouldn't have to touch the SortChanged binding and we could thus simply allow staticCommand
s here.
{ | ||
if (IsPropertySet(VisibleProperty)) | ||
throw new Exception("Visible can't be set on a DataPager when HideWhenOnlyOnePage is true. You can wrap it in an element that hide that or set HideWhenOnlyOnePage to false"); | ||
list.SetProperty(HtmlGenericControl.VisibleProperty, hasMoreThanOnePage); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this error is not new, but we can combine the Visible bindings now
if (property.GetCustomAttribute<ProtectAttribute>() is ProtectAttribute protect && protect.Settings == ProtectMode.EncryptData) | ||
{ | ||
throw new Exception($"Cannot sort by an property '{prop}' that is encrypted."); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do allow sorting by private properties through?
|
||
await r.RunCommand((CommandBindingExpression)nextPage.command, nextPage.control); | ||
Assert.AreEqual(1, (int)r.ViewModel.Customers.PagingOptions.PageIndex); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: add staticCommand datapager (just that it generates something reasonable, we have UI test for it); add AppendableDataPager
who knows if it works...
Creates a nested data context with _index and _collection extension parameters
* introduced symbolic parameters for $gridViewDataSet.loadData function. we need to substitute this loadData function on a single element, so we cannot use dotvvm-gridviewdataset to change the data context. * refactored PostbackOptions to a record to allow using `with { ... }` syntax
…ssion is multiline
0f3d026
to
3324bf6
Compare
…tor arguments are)
a2a79a6
to
4fbe3cb
Compare
Another attempt to make
GridViewDataSet
extensible and loadable on the client side.