-
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.
Add _dataPager.Load extension parameter
- Loading branch information
Showing
3 changed files
with
67 additions
and
2 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
src/Framework/Framework/Binding/HelperNamespace/DataPagerApi.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 System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Linq.Expressions; | ||
using DotVVM.Core.Storage; | ||
using DotVVM.Framework.Compilation.ControlTree; | ||
using DotVVM.Framework.Compilation.ControlTree.Resolved; | ||
using DotVVM.Framework.Compilation.Javascript.Ast; | ||
using DotVVM.Framework.Controls; | ||
|
||
namespace DotVVM.Framework.Binding.HelperNamespace | ||
{ | ||
public class DataPagerApi | ||
{ | ||
public void Load() => throw new NotSupportedException("The _dataPager.Load method is not supported on the server, please use a staticCommand to invoke it."); | ||
|
||
|
||
|
||
|
||
public class DataPagerExtensionParameter : BindingExtensionParameter | ||
{ | ||
public DataPagerExtensionParameter(string identifier, bool inherit = true) : base(identifier, ResolvedTypeDescriptor.Create(typeof(DataPagerApi)), inherit) | ||
{ | ||
} | ||
|
||
public override JsExpression GetJsTranslation(JsExpression dataContext) => | ||
new JsObjectExpression(); | ||
public override Expression GetServerEquivalent(Expression controlParameter) => | ||
Expression.New(typeof(DataPagerApi)); | ||
} | ||
|
||
public class AddParameterDataContextChangeAttribute: DataContextChangeAttribute | ||
{ | ||
public AddParameterDataContextChangeAttribute(string name = "_dataPager", int order = 0) | ||
{ | ||
Name = name; | ||
Order = order; | ||
} | ||
|
||
public string Name { get; } | ||
public override int Order { get; } | ||
|
||
public override ITypeDescriptor? GetChildDataContextType(ITypeDescriptor dataContext, IDataContextStack controlContextStack, IAbstractControl control, IPropertyDescriptor? property = null) => | ||
dataContext; | ||
public override Type? GetChildDataContextType(Type dataContext, DataContextStack controlContextStack, DotvvmBindableObject control, DotvvmProperty? property = null) => dataContext; | ||
|
||
public override IEnumerable<BindingExtensionParameter> GetExtensionParameters(ITypeDescriptor dataContext) | ||
{ | ||
return new BindingExtensionParameter[] { | ||
new DataPagerExtensionParameter(Name) | ||
}; | ||
} | ||
} | ||
} | ||
} |
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
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