DiffViewer
Namespace: Wisej.Web
Assembly: Wisej.Framework (4.2.0.0)
Compares named fields of two records and displays their old and new values.
- C#
- VB.NET
public class DiffViewer : Control
Public Class DiffViewer
Inherits Control
Supports string-keyed IDictionary records, generic string/object dictionaries and readable component-model properties. Names use ordinal, case-sensitive matching. Empty Fields discovers the sorted union of both records' browsable properties or keys; explicit Fields preserves order. Equality uses object.Equals without coercion or recursive comparison. Missing differs from null. Objects are application-owned and are not observed; call RefreshComparison after in-place edits. Property getter or format errors propagate to the caller. Only formatted text is sent to the browser.
Example:
var viewer = new DiffViewer {
OldValue = new { Stage = "Proposal", Amount = 212000m },
NewValue = new { Stage = "Negotiation", Amount = 248000m },
AllowRevert = true
};
viewer.Fields.Add(new DiffField { Name = "Amount", Format = "{0:C0}" });
viewer.RevertClick += (sender, e) => Console.WriteLine(e.Field.Name);
this.Controls.Add(viewer);
Constructors
DiffViewer()
Creates a comparison with automatic fields and unchanged rows visible.
Properties
AllowRevert
Boolean: Gets or sets whether changed fields offer a revert request button. (Default: False)
Caption
String: Gets or sets the plain-text footer caption, for example the editor and timestamp. (Default: "")
ChangesText
String: Gets or sets the composite format for the changed-field count. (Default: null)
The default is null, which uses the built-in text for the current UI culture. An empty string suppresses the text without disabling the operation. The composite format placeholder {0} is the number of changed, nonignored fields. Formatting uses CurrentCulture; translation selection uses CurrentUICulture. Literal braces must be escaped as {{ and }}.
Example:
var control = new DiffViewer();
control.ChangesText = "{0} modified fields";
control.ChangesText = null; // Restore the built-in localized text.
DefaultSize
Size: Gets the initial comparison surface size.
Fields
DiffFieldCollection: Gets the ordered field descriptors. Empty enables automatic discovery.
Focusable
Boolean: Gets or sets whether the viewer can receive the focus. The default is false. (Default: False)
HideText
String: Gets or sets the composite format for the hide-unchanged button caption. (Default: null)
The default is null, which uses the built-in text for the current UI culture. An empty string suppresses the text without disabling the operation. The composite format placeholder {0} is the number of unchanged, nonignored fields. Formatting uses CurrentCulture. Literal braces must be escaped as {{ and }}.
IgnoreFields
String[]: Gets or sets exact field names excluded from both automatic and explicit fields.
The array is copied on assignment and retrieval. Null resets to an empty array.
MissingText
String: Gets or sets the text displayed for an absent field. (Default: null)
The default is null, which uses the built-in text for the current UI culture. An empty string suppresses the text without disabling the operation.
Mode
DiffViewerMode: Gets or sets the value layout. The default is SideBySide. (Default: SideBySide)
NewValue
Object: Gets or sets the new application-owned record. Null has no fields. (Default: null)
NullText
String: Gets or sets the text displayed for a null field value. (Default: null)
The default is null, which uses the built-in text for the current UI culture. An empty string suppresses the text without disabling the operation.
OldValue
Object: Gets or sets the old application-owned record. Null has no fields. (Default: null)
RevertText
String: Gets or sets the revert button tooltip. (Default: null)
The default is null, which uses the built-in text for the current UI culture. An empty string suppresses the text without disabling the operation.
ShowText
String: Gets or sets the composite format for the show-unchanged button caption. (Default: null)
The default is null, which uses the built-in text for the current UI culture. An empty string suppresses the text without disabling the operation. The composite format placeholder {0} is the number of unchanged, nonignored fields. Formatting uses CurrentCulture. Literal braces must be escaped as {{ and }}.
ShowUnchanged
Boolean: Gets or sets whether unchanged fields are visible. The footer can toggle this property. (Default: True)
TabStop
Boolean: Gets or sets whether the viewer takes part in tab navigation. The default is false. (Default: False)
UnchangedText
String: Gets or sets the caption for an unchanged field. (Default: null)
The default is null, which uses the built-in text for the current UI culture. An empty string suppresses the text without disabling the operation.
Methods
Dispose(disposing)
Releases field observers without disposing either application-owned record.
| Parameter | Type | Description |
|---|---|---|
| disposing | Boolean | Whether managed resources can be released. |
OnFieldClick(e)
Raises FieldClick.
| Parameter | Type | Description |
|---|---|---|
| e | DiffFieldEventArgs | The rendered field comparison. |
OnRevertClick(e)
Raises RevertClick.
| Parameter | Type | Description |
|---|---|---|
| e | DiffFieldEventArgs | The rendered field comparison. |
OnWebEvent(e)
Dispatches browser interactions to validated processors.
| Parameter | Type | Description |
|---|---|---|
| e | WisejEventArgs | Client event data. |
OnWebRender(config)
Renders first-level options and a versioned text-only comparison snapshot.
| Parameter | Type | Description |
|---|---|---|
| config | Object | Client configuration. |
RefreshComparison()
Invalidates the rendered comparison after in-place changes to either record.
Example:
newRecord["Stage"] = "Approved";
viewer.RefreshComparison();
Events
FieldClick
EventHandler<DiffFieldEventArgs> Occurs when a displayed field is activated by mouse or keyboard.
RevertClick
EventHandler<DiffFieldEventArgs> Occurs when a changed field requests a revert; neither record is modified.
Implements
| Name | Description |
|---|---|
| IUserData | Provides access to the UserData and Tag properties associated to the component implementing this interface. |
| IBindableComponent | Bindable components implement this interface. |
| IDropTarget | Controls that support drag & drop operations implement this interface. |
| IWisejComponent | All wisej components implement this interface. |
| IWisejControl | All wisej controls derived from the Control class must implement this interface. |
| IWisejSerializable | Allows an object to serialize itself. |