Skip to content

Commit 8beb92a

Browse files
authored
docs(Grid): add docs for new row position feature (#3096)
* docs(Grid): add docs for new row position feature * chore: apply review recommendations
1 parent 7529e5d commit 8beb92a

File tree

9 files changed

+156
-30
lines changed

9 files changed

+156
-30
lines changed

components/gantt/gantt-tree/editing/incell.md

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,18 @@ Command columns and non-editable columns are skipped while tabbing.
1818

1919
The InCell edit mode provides a specific user experience and behaves differently than other edit modes. Please review the notes below to get a better understanding of these specifics.
2020

21+
## New Row Position
22+
23+
To control whether a newly added item appears at the top or bottom of the Gantt Tree, set the `NewRowPosition` parameter.
24+
25+
The `NewRowPosition` parameter accepts values from the `GanttTreeListNewRowPosition` enum:
26+
27+
- `Top` (default)—Inserts the new item at the top of the view.
28+
- `Bottom`—Inserts the new item at the bottom of the view.
29+
2130
### Note
2231
It is up to the data access logic to save the data once it is changed in the data collection, or to revert changes. The example above showcases the events that allow you to do that. In a real application, the code for handling data operations may be entirely different.
2332

24-
2533
>caption InCell Editing Example.
2634
2735
````RAZOR
@@ -68,20 +76,9 @@ It is up to the data access logic to save the data once it is changed in the dat
6876
</TelerikGantt>
6977
7078
@code {
71-
public DateTime SelectedDate { get; set; } = new DateTime(2019, 11, 11, 6, 0, 0);
72-
73-
class FlatModel
74-
{
75-
public int Id { get; set; }
76-
public int? ParentId { get; set; }
77-
public string Title { get; set; }
78-
public double PercentComplete { get; set; }
79-
public DateTime Start { get; set; }
80-
public DateTime End { get; set; }
81-
}
82-
83-
public int LastId { get; set; } = 1;
84-
List<FlatModel> Data { get; set; }
79+
private DateTime SelectedDate { get; set; } = new DateTime(2019, 11, 11, 6, 0, 0);
80+
private int LastId { get; set; } = 1;
81+
private List<FlatModel> Data { get; set; }
8582
8683
protected override void OnInitialized()
8784
{
@@ -122,6 +119,16 @@ It is up to the data access logic to save the data once it is changed in the dat
122119
base.OnInitialized();
123120
}
124121
122+
public class FlatModel
123+
{
124+
public int Id { get; set; }
125+
public int? ParentId { get; set; }
126+
public string Title { get; set; }
127+
public double PercentComplete { get; set; }
128+
public DateTime Start { get; set; }
129+
public DateTime End { get; set; }
130+
}
131+
125132
private async Task CreateItem(GanttCreateEventArgs args)
126133
{
127134
var argsItem = args.Item as FlatModel;
@@ -251,4 +258,3 @@ It is up to the data access logic to save the data once it is changed in the dat
251258
## See Also
252259

253260
* [Live Demo: Gantt InCell Editing](https://demos.telerik.com/blazor-ui/gantt/editing-incell)
254-

components/gantt/gantt-tree/editing/inline.md

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ You can also cancel the events by setting the `IsCancelled` property of the even
2020

2121
To enable Inline editing in the Gantt Tree, set its `TreeListEditMode` property to `GanttTreeListEditMode.Inline`, then handle the CRUD events as shown in the example below.
2222

23+
## New Row Position
24+
25+
To control whether a newly added item appears at the top or bottom of the Gantt Tree, set the `NewRowPosition` parameter.
26+
27+
The `NewRowPosition` parameter accepts values from the `GanttTreeListNewRowPosition` enum:
28+
29+
- `Top` (default)&mdash;Inserts the new item at the top of the view.
30+
- `Bottom`&mdash;Inserts the new item at the bottom of the view.
2331

2432
>caption The Command buttons and the Gantt events let you handle data operations in Inline edit mode.
2533
@@ -70,20 +78,9 @@ To enable Inline editing in the Gantt Tree, set its `TreeListEditMode` property
7078
</TelerikGantt>
7179
7280
@code {
73-
public DateTime SelectedDate { get; set; } = new DateTime(2019, 11, 11, 6, 0, 0);
74-
75-
class FlatModel
76-
{
77-
public int Id { get; set; }
78-
public int? ParentId { get; set; }
79-
public string Title { get; set; }
80-
public double PercentComplete { get; set; }
81-
public DateTime Start { get; set; }
82-
public DateTime End { get; set; }
83-
}
84-
85-
public int LastId { get; set; } = 1;
86-
List<FlatModel> Data { get; set; }
81+
private DateTime SelectedDate { get; set; } = new DateTime(2019, 11, 11, 6, 0, 0);
82+
private int LastId { get; set; } = 1;
83+
private List<FlatModel> Data { get; set; }
8784
8885
protected override void OnInitialized()
8986
{
@@ -124,6 +121,16 @@ To enable Inline editing in the Gantt Tree, set its `TreeListEditMode` property
124121
base.OnInitialized();
125122
}
126123
124+
public class FlatModel
125+
{
126+
public int Id { get; set; }
127+
public int? ParentId { get; set; }
128+
public string Title { get; set; }
129+
public double PercentComplete { get; set; }
130+
public DateTime Start { get; set; }
131+
public DateTime End { get; set; }
132+
}
133+
127134
private async Task CreateItem(GanttCreateEventArgs args)
128135
{
129136
var argsItem = args.Item as FlatModel;

components/gantt/gantt-tree/editing/overview.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,30 @@ You can customize the editors rendered in the Gantt Tree by providing the `Edito
298298

299299
* `IsCanceled`- a boolean field indicating whether the operation is to be prevented.
300300

301+
## New Row Position
302+
303+
You can control whether a newly added item appears at the top or bottom of the Gantt Tree. Use the [`NewRowPosition`](https://www.telerik.com/blazor-ui/documentation/api/telerik.blazor.gantttreelistnewrowposition) parameter to specify the position. This parameter does not affect Popup edit mode, which always displays a dialog for new items.
304+
305+
This configuration is available in InCell and Inline edit modes. For more details, see the [Tree InCell Editing](slug:gant-tree-incell-editing#new-row-position) and [Tree Inline Editing](slug:gant-tree-inline-editing#new-row-position) articles.
306+
307+
> When you set `NewRowPosition` to `Bottom`, add the new item at the end of your data collection in the `OnCreate` event handler. When set to `Top`, insert the new item at the beginning of the collection. This ensures the new row appears in the correct position in the view after successfully creating the new record.
308+
309+
>caption Example of adding a new item to the Gantt based on the `NewRowPosition` value
310+
311+
<div class="skip-repl"></div>
312+
````C#
313+
private void OnCreate(GanttCreateEventArgs args)
314+
{
315+
if (NewRowPosition == GanttTreeListNewRowPosition.Bottom)
316+
{
317+
dataCollection.Add(newItem);
318+
}
319+
else // Top
320+
{
321+
dataCollection.Insert(0, newItem);
322+
}
323+
}
324+
````
301325

302326
## Example
303327

components/grid/editing/incell.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,17 @@ In in-cell edit mode, the `OnAdd` and `OnCreate` events fire immediately one aft
5454

5555
The above algorithm is different from [inline](slug:grid-editing-inline) and [popup](slug:grid-editing-popup) editing where new rows are only added to the data source after users populate them with valid values.
5656

57+
## New Row Position
58+
59+
You can control whether a newly added item appears at the top or bottom of the Grid. Use the `NewRowPosition` parameter to specify the position.
60+
61+
The `NewRowPosition` parameter accepts values from the `GridNewRowPosition` enum:
62+
63+
- `Top` (default)&mdash;Inserts the new item at the top of the view.
64+
- `Bottom`&mdash;Inserts the new item at the bottom of the view.
65+
66+
For a complete example of how this feature works, see the following [example](slug:grid-editing-incell#basic).
67+
5768
## Integration with Other Features
5869

5970
Here is how the component behaves when the user tries to use add and edit operations together with other component features. Also check the [common information on this topic for all edit modes](slug:grid-editing-overview#integration-with-other-features).

components/grid/editing/inline.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@ In inline edit mode, the Grid commands execute row by row and the corresponding
3939

4040
When validation is not satisfied, clicking the **Save**, **Delete** or **Add** command buttons have no effect, but users can still navigate between all input components in the row to complete the editing.
4141

42+
## New Row Position
43+
44+
You can control whether a newly added item appears at the top or bottom of the Grid. Use the `NewRowPosition` parameter to specify the position.
45+
46+
The `NewRowPosition` parameter accepts values from the `GridNewRowPosition` enum:
47+
48+
- `Top` (default)&mdash;Inserts the new item at the top of the view.
49+
- `Bottom`&mdash;Inserts the new item at the bottom of the view.
50+
4251
## Integration with Other Features
4352

4453
Here is how the component behaves when the user tries to use add and edit operations together with other component features. Also check the [common information on this topic for all edit modes](slug:grid-editing-overview#integration-with-other-features).

components/grid/editing/overview.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,32 @@ When editing a master row in a [hierarchy Grid](slug://components/grid/features/
205205

206206
Learn more integration details for the [inline](slug:grid-editing-inline#integration-with-other-features) and [in-cell](slug:grid-editing-incell#integration-with-other-features) edit modes.
207207

208+
209+
## New Row Position
210+
211+
You can control whether a newly added item appears at the top or bottom of the Grid. Use the [`NewRowPosition`](https://www.telerik.com/blazor-ui/documentation/api/telerik.blazor.gridnewrowposition) parameter to specify the position. This parameter does not affect Popup edit mode, which always displays a dialog for new items.
212+
213+
This configuration is available in InCell and Inline edit modes. For more details, see the [InCell Editing](slug:grid-editing-incell#new-row-position) and [Inline Editing](slug:grid-editing-inline#new-row-position) articles.
214+
215+
> When you set `NewRowPosition` to `Bottom`, add the new item at the end of your data collection in the `OnCreate` event handler. When set to `Top`, insert the new item at the beginning of the collection. This ensures the new row appears in the correct position in the view after successfully creating the new record.
216+
217+
>caption Example of adding a new item to the Grid based on the `NewRowPosition` value
218+
219+
<div class="skip-repl"></div>
220+
````C#
221+
private void OnCreate(GridCommandEventArgs args)
222+
{
223+
if (NewRowPosition == GridNewRowPosition.Bottom)
224+
{
225+
dataCollection.Add(newItem);
226+
}
227+
else // Top
228+
{
229+
dataCollection.Insert(0, newItem);
230+
}
231+
}
232+
````
233+
208234
## Examples
209235

210236
See Grid CRUD operations in action at:

components/treelist/editing/incell.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,15 @@ In in-cell edit mode, the `OnAdd` and `OnCreate` events fire immediately one aft
5454

5555
The above algorithm is different from [inline](slug:treelist-editing-inline) and [popup](slug:treelist-editing-popup) editing where new rows are only added to the data source after users populate them with valid values.
5656

57+
## New Row Position
58+
59+
You can control whether a newly added item appears at the top or bottom of the TreeList. Use the `NewRowPosition` parameter to specify the position.
60+
61+
The `NewRowPosition` parameter accepts values from the `TreeListNewRowPosition` enum:
62+
63+
- `Top` (default)&mdash;Inserts the new item at the top of the view.
64+
- `Bottom`&mdash;Inserts the new item at the bottom of the view.
65+
5766
## Integration with Other Features
5867

5968
Here is how the component behaves when the user tries to use add and edit operations together with other component features. Also check the [common information on this topic for all edit modes](slug:treelist-editing-overview#integration-with-other-features).

components/treelist/editing/inline.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@ In inline edit mode, the TreeList commands execute row by row and the correspond
3939

4040
When validation is not satisfied, clicking the **Save**, **Delete** or **Add** command buttons has no effect, but users can still navigate between all input components in the row to complete the editing.
4141

42+
## New Row Position
43+
44+
You can control whether a newly added item appears at the top or bottom of the TreeList. Use the `NewRowPosition` parameter to specify the position. This parameter does not affect Popup edit mode, which always displays a dialog for new items.
45+
46+
The `NewRowPosition` parameter accepts values from the `TreeListNewRowPosition` enum:
47+
48+
- `Top` (default)&mdash;Inserts the new item at the top of the view.
49+
- `Bottom`&mdash;Inserts the new item at the bottom of the view.
50+
4251
## Integration with Other Features
4352

4453
Here is how the component behaves when the user tries to use add and edit operations together with other component features. Also check the [common information on this topic for all edit modes](slug:treelist-editing-overview#integration-with-other-features).

components/treelist/editing/overview.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,31 @@ When editing a row with child items, it will collapse unless you override the `E
192192

193193
Learn more integration details for the [inline](slug:treelist-editing-inline#integration-with-other-features) and [in-cell](slug:treelist-editing-incell#integration-with-other-features) edit modes.
194194

195+
## New Row Position
196+
197+
You can control whether a newly added item appears at the top or bottom of the TreeList. Use the [`NewRowPosition`](https://www.telerik.com/blazor-ui/documentation/api/telerik.blazor.treelistnewrowposition) parameter to specify the position. This parameter does not affect Popup edit mode, which always displays a dialog for new items.
198+
199+
This configuration is available in InCell and Inline edit modes. For more details, see the [InCell Editing](slug:treelist-editing-incell#new-row-position) and [Inline Editing](slug:treelist-editing-inline#new-row-position) articles.
200+
201+
> When you set `NewRowPosition` to `Bottom`, add the new item at the end of your data collection in the `OnCreate` event handler. When set to `Top`, insert the new item at the beginning of the collection. This ensures the new row appears in the correct position in the view after successfully creating the new record.
202+
203+
>caption Example of adding a new item to the TreeList based on the `NewRowPosition` value
204+
205+
<div class="skip-repl"></div>
206+
````C#
207+
private void OnCreate(TreeListCommandEventArgs args)
208+
{
209+
if (NewRowPosition == TreeListNewRowPosition.Bottom)
210+
{
211+
dataCollection.Add(newItem);
212+
}
213+
else // Top
214+
{
215+
dataCollection.Insert(0, newItem);
216+
}
217+
}
218+
````
219+
195220
## Examples
196221

197222
See TreeList CRUD operations in action at:

0 commit comments

Comments
 (0)