Skip to content

Commit c8154b0

Browse files
authored
Merge pull request #1 from IgniteUI/dpetev/api-align-refactor
API align refactor
2 parents 9c26dc6 + 007c661 commit c8154b0

16 files changed

+115
-115
lines changed

README.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,18 @@ In your `App.razor` or layout file, include one of the available themes:
5656
5757
@code {
5858
private List<Employee> employees = new();
59-
private List<ColumnConfiguration<Employee>> columns = new();
59+
private List<IgbColumnConfiguration> columns = new();
6060
6161
protected override void OnInitialized()
6262
{
6363
employees = GetEmployees();
6464
65-
columns = new List<ColumnConfiguration<Employee>>
65+
columns = new List<IgbColumnConfiguration>
6666
{
67-
new() { Key = nameof(Employee.Id), HeaderText = "ID", Width = "100px", Type = DataType.Number },
68-
new() { Key = nameof(Employee.Name), HeaderText = "Employee Name", Type = DataType.String },
69-
new() { Key = nameof(Employee.Department), HeaderText = "Department", Type = DataType.String },
70-
new() { Key = nameof(Employee.Salary), HeaderText = "Salary", Width = "150px", Type = DataType.Number }
67+
new() { Key = nameof(Employee.Id), HeaderText = "ID", Width = "100px", Type = GridLiteColumnDataType.Number },
68+
new() { Key = nameof(Employee.Name), HeaderText = "Employee Name", Type = GridLiteColumnDataType.String },
69+
new() { Key = nameof(Employee.Department), HeaderText = "Department", Type = GridLiteColumnDataType.String },
70+
new() { Key = nameof(Employee.Salary), HeaderText = "Salary", Width = "150px", Type = GridLiteColumnDataType.Number }
7171
};
7272
}
7373
}
@@ -82,12 +82,12 @@ In your `App.razor` or layout file, include one of the available themes:
8282
FilterExpressions="@initialFilter" />
8383
8484
@code {
85-
private List<SortExpression> initialSort = new()
85+
private List<IgbGridLiteSortExpression> initialSort = new()
8686
{
8787
new() { Key = nameof(Employee.Name), Direction = GridLiteSortingDirection.Ascending }
8888
};
8989
90-
private List<FilterExpression> initialFilter = new()
90+
private List<IgbGridLiteFilterExpression> initialFilter = new()
9191
{
9292
new() { Key = nameof(Employee.Department), Condition = "contains", SearchTerm = "Sales" }
9393
};
@@ -101,7 +101,7 @@ In your `App.razor` or layout file, include one of the available themes:
101101
Enable sorting on specific columns:
102102

103103
```csharp
104-
new ColumnConfiguration<Employee>
104+
new IgbColumnConfiguration
105105
{
106106
Key = nameof(Employee.Name),
107107
HeaderText = "Name",
@@ -115,11 +115,11 @@ new ColumnConfiguration<Employee>
115115
Enable filtering on columns:
116116

117117
```csharp
118-
new ColumnConfiguration<Employee>
118+
new IgbColumnConfiguration
119119
{
120120
Key = nameof(Employee.Department),
121121
HeaderText = "Department",
122-
Filter = new ColumnFilterConfiguration
122+
Filter = new IgbColumnFilterConfiguration
123123
{
124124
CaseSensitive = false
125125
}
@@ -133,28 +133,28 @@ Handle sorting and filtering events:
133133
```razor
134134
<IgbGridLite Data="@employees"
135135
Columns="@columns"
136-
OnSorting="@HandleSorting"
137-
OnSorted="@HandleSorted"
138-
OnFiltering="@HandleFiltering"
139-
OnFiltered="@HandleFiltered" />
136+
Sorting="@HandleSorting"
137+
Sorted="@HandleSorted"
138+
Filtering="@HandleFiltering"
139+
Filtered="@HandleFiltered" />
140140
141141
@code {
142-
private void HandleSorting(IgbGridLiteSortingEvent e)
142+
private void HandleSorting(IgbGridLiteSortingEventArgs e)
143143
{
144144
// Handle on sorting
145145
}
146146
147-
private void HandleSorted(IgbGridLiteSortedEvent e)
147+
private void HandleSorted(IgbGridLiteSortedEventArgs e)
148148
{
149149
// Handle after sort
150150
}
151151
152-
private void HandleFiltering(IgbGridLiteFilteringEvent e)
152+
private void HandleFiltering(IgbGridLiteFilteringEventArgs e)
153153
{
154154
// Handle on filtering
155155
}
156156
157-
private void HandleFiltered(IgbGridLiteFilteredEvent e)
157+
private void HandleFiltered(IgbGridLiteFilteredEventArgs e)
158158
{
159159
// Handle after filter
160160
}
@@ -163,7 +163,7 @@ Handle sorting and filtering events:
163163

164164
## Column Configuration
165165

166-
The `ColumnConfiguration<TItem>` class supports:
166+
The `IgbColumnConfiguration` class supports:
167167

168168
- `Key`: Property name to bind to (use `nameof()` for type safety)
169169
- `HeaderText`: Column header display text

demo/GridLite.DemoApp/Components/Pages/Home.razor

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
SortConfiguration="@sortConfiguration" Columns="cols"
55
SortExpressions="@initialSort"
66
FilterExpressions="@initialFilter"
7-
OnSorting="HandleSorting" OnSorted="HandleSorted"
8-
OnFiltering="HandleFiltering" OnFiltered="HandleFiltered">
7+
Sorting="HandleSorting" Sorted="HandleSorted"
8+
Filtering="HandleFiltering" Filtered="HandleFiltered">
99

1010
</IgbGridLite>
1111

@@ -14,36 +14,36 @@
1414
@code {
1515
public IgbGridLite<NwindDataItem> grid;
1616

17-
private GridSortConfiguration sortConfiguration = new GridSortConfiguration()
17+
private IgbGridLiteSortConfiguration sortConfiguration = new IgbGridLiteSortConfiguration()
1818
{
1919
Multiple = true,
2020
TriState = false
2121
};
2222

23-
private List<SortExpression> initialSort;
24-
private List<FilterExpression> initialFilter;
23+
private List<IgbGridLiteSortExpression> initialSort;
24+
private List<IgbGridLiteFilterExpression> initialFilter;
2525

2626
protected override void OnInitialized()
2727
{
28-
initialFilter = new List<FilterExpression>
28+
initialFilter = new List<IgbGridLiteFilterExpression>
2929
{
30-
new FilterExpression
30+
new IgbGridLiteFilterExpression
3131
{
3232
Key = nameof(NwindDataItem.ProductName),
3333
Condition = "contains",
3434
SearchTerm = "a"
3535
},
36-
new FilterExpression
36+
new IgbGridLiteFilterExpression
3737
{
3838
Key = nameof(NwindDataItem.ProductName),
3939
Condition = "contains",
4040
SearchTerm = "b"
4141
}
4242
};
4343

44-
initialSort = new List<SortExpression>
44+
initialSort = new List<IgbGridLiteSortExpression>
4545
{
46-
new SortExpression
46+
new IgbGridLiteSortExpression
4747
{
4848
Key = nameof(NwindDataItem.ProductName),
4949
Direction = GridLiteSortingDirection.Ascending
@@ -53,9 +53,9 @@
5353

5454
public async void BtnClick()
5555
{
56-
await this.grid.SortAsync(new List<SortExpression>
56+
await this.grid.SortAsync(new List<IgbGridLiteSortExpression>
5757
{
58-
new SortExpression() { Key = nameof(NwindDataItem.ProductName), Direction = GridLiteSortingDirection.Descending }
58+
new IgbGridLiteSortExpression() { Key = nameof(NwindDataItem.ProductName), Direction = GridLiteSortingDirection.Descending }
5959
}
6060
);
6161
}
@@ -74,42 +74,42 @@
7474
}
7575
}
7676

77-
private void HandleSorting(IgbGridLiteSortingEvent e)
77+
private void HandleSorting(IgbGridLiteSortingEventArgs e)
7878
{
7979

8080
}
8181

82-
private void HandleSorted(IgbGridLiteSortedEvent e)
82+
private void HandleSorted(IgbGridLiteSortedEventArgs e)
8383
{
8484

8585
}
8686

87-
private void HandleFiltering(IgbGridLiteFilteringEvent e)
87+
private void HandleFiltering(IgbGridLiteFilteringEventArgs e)
8888
{
8989

9090
}
9191

92-
private void HandleFiltered(IgbGridLiteFilteredEvent e)
92+
private void HandleFiltered(IgbGridLiteFilteredEventArgs e)
9393
{
9494

9595
}
9696

97-
public List<ColumnConfiguration<NwindDataItem>> cols = new List<ColumnConfiguration<NwindDataItem>>() {
98-
new ColumnConfiguration<NwindDataItem>(){
99-
Key = nameof(NwindDataItem.ProductID),
100-
Type = DataType.Number,
101-
Sort = new ColumnSortConfiguration(){
102-
CaseSensitive = false
97+
public List<IgbColumnConfiguration> cols = new List<IgbColumnConfiguration> {
98+
new IgbColumnConfiguration {
99+
Key = nameof(NwindDataItem.ProductID),
100+
Type = GridLiteColumnDataType.Number,
101+
Sort = new IgbColumnSortConfiguration {
102+
CaseSensitive = false
103+
},
104+
Filter = true,
105+
Resizable = true
106+
},
107+
new IgbColumnConfiguration {
108+
Key = nameof(NwindDataItem.ProductName),
109+
Type = GridLiteColumnDataType.String,
110+
Sort = true,
111+
Filter = true,
112+
Resizable = true
103113
},
104-
Filter = true,
105-
Resizable = true
106-
},
107-
new ColumnConfiguration<NwindDataItem>(){
108-
Key = nameof(NwindDataItem.ProductName),
109-
Type = DataType.String,
110-
Sort = true,
111-
Filter = true,
112-
Resizable = true
113-
},
114114
};
115115
}

src/IgniteUI.Blazor.GridLite/IgbGridLite.razor.cs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public partial class IgbGridLite<TItem> : ComponentBase, IDisposable where TItem
2323
/// Column configurations for the grid
2424
/// </summary>
2525
[Parameter]
26-
public List<ColumnConfiguration<TItem>>? Columns { get; set; }
26+
public List<IgbColumnConfiguration>? Columns { get; set; }
2727

2828
/// <summary>
2929
/// The options to customize the grid with
@@ -45,19 +45,19 @@ public partial class IgbGridLite<TItem> : ComponentBase, IDisposable where TItem
4545
/// Sort configuration property for the grid.
4646
/// </summary>
4747
[Parameter]
48-
public GridSortConfiguration? SortConfiguration { get; set; }
48+
public IgbGridLiteSortConfiguration? SortConfiguration { get; set; }
4949

5050
/// <summary>
5151
/// Initial sort expressions to apply when the grid is rendered
5252
/// </summary>
5353
[Parameter]
54-
public IEnumerable<SortExpression>? SortExpressions { get; set; }
54+
public IEnumerable<IgbGridLiteSortExpression>? SortExpressions { get; set; }
5555

5656
/// <summary>
5757
/// Initial filter expressions to apply when the grid is rendered
5858
/// </summary>
5959
[Parameter]
60-
public IEnumerable<FilterExpression>? FilterExpressions { get; set; }
60+
public IEnumerable<IgbGridLiteFilterExpression>? FilterExpressions { get; set; }
6161

6262
/// <summary>
6363
/// Additional attributes for the component's HTML element
@@ -75,14 +75,14 @@ public partial class IgbGridLite<TItem> : ComponentBase, IDisposable where TItem
7575
/// The expression can be modified prior to the operation running.
7676
/// </remarks>
7777
[Parameter]
78-
public EventCallback<IgbGridLiteSortingEvent> OnSorting { get; set; }
78+
public EventCallback<IgbGridLiteSortingEventArgs> Sorting { get; set; }
7979

8080
/// <summary>
8181
/// Fires when a sort operation initiated through the UI has completed.
8282
/// Returns the sort expression used for the operation.
8383
/// </summary>
8484
[Parameter]
85-
public EventCallback<IgbGridLiteSortedEvent> OnSorted { get; set; }
85+
public EventCallback<IgbGridLiteSortedEventArgs> Sorted { get; set; }
8686

8787
/// <summary>
8888
/// Fires when filtering is initiated through the UI.
@@ -92,20 +92,20 @@ public partial class IgbGridLite<TItem> : ComponentBase, IDisposable where TItem
9292
/// The expression can be modified prior to the operation running.
9393
/// </remarks>
9494
[Parameter]
95-
public EventCallback<IgbGridLiteFilteringEvent> OnFiltering { get; set; }
95+
public EventCallback<IgbGridLiteFilteringEventArgs> Filtering { get; set; }
9696

9797
/// <summary>
9898
/// Fires when a filter operation initiated through the UI has completed.
9999
/// Returns the filter state for the affected column.
100100
/// </summary>
101101
[Parameter]
102-
public EventCallback<IgbGridLiteFilteredEvent> OnFiltered { get; set; }
102+
public EventCallback<IgbGridLiteFilteredEventArgs> Filtered { get; set; }
103103

104104
/// <summary>
105105
/// Fires when <see cref="RenderAsync"/> completes
106106
/// </summary>
107107
[Parameter]
108-
public EventCallback OnRendered { get; set; }
108+
public EventCallback Rendered { get; set; }
109109

110110
private ElementReference grid;
111111
private IJSObjectReference blazorIgbGridLite;
@@ -203,17 +203,17 @@ private async Task RenderGridAsync()
203203
await InvokeVoidJsAsync("blazor_igc_grid_lite.renderGrid",
204204
jsHandler.ObjectReference, grid, json, GetEventFlags());
205205

206-
await OnRendered.InvokeAsync();
206+
await Rendered.InvokeAsync();
207207
}
208208

209209
private object GetEventFlags()
210210
{
211211
return new
212212
{
213-
hasSorting = OnSorting.HasDelegate,
214-
hasSorted = OnSorted.HasDelegate,
215-
hasFiltering = OnFiltering.HasDelegate,
216-
hasFiltered = OnFiltered.HasDelegate
213+
hasSorting = Sorting.HasDelegate,
214+
hasSorted = Sorted.HasDelegate,
215+
hasFiltering = Filtering.HasDelegate,
216+
hasFiltered = Filtered.HasDelegate
217217
};
218218
}
219219

@@ -241,7 +241,7 @@ public virtual async Task UpdateDataAsync(IEnumerable<TItem> newData)
241241
/// Updates the column configurations for the grid.
242242
/// </summary>
243243
/// <param name="newColumns">The new column configurations</param>
244-
public virtual async Task UpdateColumnsAsync(List<ColumnConfiguration<TItem>> newColumns)
244+
public virtual async Task UpdateColumnsAsync(List<IgbColumnConfiguration> newColumns)
245245
{
246246
Columns = newColumns;
247247
var json = JsonSerializer.Serialize(newColumns.Select(c => c.ToJsConfig()), GridJsonSerializerOptions);
@@ -252,7 +252,7 @@ public virtual async Task UpdateColumnsAsync(List<ColumnConfiguration<TItem>> ne
252252
/// Performs a sort operation in the grid based on the passed expression(s).
253253
/// </summary>
254254
/// <param name="expressions">The sort expression(s) to apply</param>
255-
public virtual async Task SortAsync(SortExpression expressions)
255+
public virtual async Task SortAsync(IgbGridLiteSortExpression expressions)
256256
{
257257
var json = JsonSerializer.Serialize(expressions, GridJsonSerializerOptions);
258258
await InvokeVoidJsAsync("blazor_igc_grid_lite.sort", gridId, json);
@@ -262,7 +262,7 @@ public virtual async Task SortAsync(SortExpression expressions)
262262
/// Performs a sort operation in the grid based on the passed expression(s).
263263
/// </summary>
264264
/// <param name="expressions">The sort expression(s) to apply</param>
265-
public virtual async Task SortAsync(List<SortExpression> expressions)
265+
public virtual async Task SortAsync(List<IgbGridLiteSortExpression> expressions)
266266
{
267267
var json = JsonSerializer.Serialize(expressions, GridJsonSerializerOptions);
268268
await InvokeVoidJsAsync("blazor_igc_grid_lite.sort", gridId, json);
@@ -282,7 +282,7 @@ public virtual async Task ClearSortAsync(string key = null)
282282
/// Performs a filter operation in the grid based on the passed expression(s).
283283
/// </summary>
284284
/// <param name="expressions">The filter expression(s) to apply</param>
285-
public virtual async Task FilterAsync(FilterExpression expression)
285+
public virtual async Task FilterAsync(IgbGridLiteFilterExpression expression)
286286
{
287287
var json = JsonSerializer.Serialize(expression, GridJsonSerializerOptions);
288288
await InvokeVoidJsAsync("blazor_igc_grid_lite.filter", gridId, json);
@@ -292,7 +292,7 @@ public virtual async Task FilterAsync(FilterExpression expression)
292292
/// Performs a filter operation in the grid based on the passed expression(s).
293293
/// </summary>
294294
/// <param name="expressions">The filter expression(s) to apply</param>
295-
public virtual async Task FilterAsync(List<FilterExpression> expressions)
295+
public virtual async Task FilterAsync(List<IgbGridLiteFilterExpression> expressions)
296296
{
297297
var json = JsonSerializer.Serialize(expressions, GridJsonSerializerOptions);
298298
await InvokeVoidJsAsync("blazor_igc_grid_lite.filter", gridId, json);
@@ -313,7 +313,7 @@ public virtual async Task ClearFilterAsync(string key = null)
313313
/// </summary>
314314
/// <param name="key">The column key to retrieve</param>
315315
/// <returns>The column configuration if found, otherwise null</returns>
316-
public virtual ColumnConfiguration<TItem> GetColumn(string key)
316+
public virtual IgbColumnConfiguration GetColumn(string key)
317317
{
318318
return Columns?.FirstOrDefault(c => c.Key == key);
319319
}
@@ -323,7 +323,7 @@ public virtual ColumnConfiguration<TItem> GetColumn(string key)
323323
/// </summary>
324324
/// <param name="index">The zero-based column index</param>
325325
/// <returns>The column configuration if found, otherwise null</returns>
326-
public virtual ColumnConfiguration<TItem> GetColumn(int index)
326+
public virtual IgbColumnConfiguration GetColumn(int index)
327327
{
328328
return Columns?.ElementAtOrDefault(index);
329329
}

0 commit comments

Comments
 (0)