You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: components/treelist/events.md
+122Lines changed: 122 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -20,6 +20,7 @@ This article explains the events available in the Telerik TreeList for Blazor. T
20
20
* [OnModelInit](#onmodelinit)
21
21
* [OnRowClick](#onrowclick)
22
22
* [OnRowDoubleClick](#onrowdoubleclick)
23
+
* [OnRowContextMenu](#onrowcontextmenu)
23
24
* [OnRowRender](#onrowrender)
24
25
* [OnRowDrop](#onrowdrop)
25
26
* [PageChanged](#pagechanged)
@@ -1165,6 +1166,127 @@ The `OnRowDoubleClick` event fires before selection happens.
1165
1166
}
1166
1167
````
1167
1168
1169
+
### OnRowContextMenu
1170
+
1171
+
The `OnRowContextMenu` event fires as a response to the user right clicking action on a row of the TreeList, the context menu keyboard button or long-touch for mobile devices. The event does not fire when clicking on:
1172
+
*`TreeListCommandButton`
1173
+
* row selection checkbox
1174
+
* expand/collapse button
1175
+
* row in edit mode
1176
+
1177
+
The event handler receives a `TreeListRowClickEventArgs` object. It provides the model of the clicked row in the `Item` field that you can cast to your model type.
// denote the parent-child relationship between items
1232
+
public int Id { get; set; }
1233
+
public int? ParentId { get; set; }
1234
+
1235
+
// custom data fields for display
1236
+
public string Name { get; set; }
1237
+
public string EmailAddress { get; set; }
1238
+
public DateTime HireDate { get; set; }
1239
+
}
1240
+
1241
+
// data generation
1242
+
1243
+
async Task<List<Employee>> GetTreeListData()
1244
+
{
1245
+
List<Employee> data = new List<Employee>();
1246
+
1247
+
for (int i = 1; i < 15; i++)
1248
+
{
1249
+
data.Add(new Employee
1250
+
{
1251
+
Id = i,
1252
+
ParentId = null, // indicates a root-level item
1253
+
Name = $"root: {i}",
1254
+
EmailAddress = $"{i}@example.com",
1255
+
HireDate = DateTime.Now.AddYears(-i)
1256
+
}); ;
1257
+
1258
+
for (int j = 1; j < 4; j++)
1259
+
{
1260
+
int currId = i * 100 + j;
1261
+
data.Add(new Employee
1262
+
{
1263
+
Id = currId,
1264
+
ParentId = i,
1265
+
Name = $"first level child {j} of {i}",
1266
+
EmailAddress = $"{currId}@example.com",
1267
+
HireDate = DateTime.Now.AddDays(-currId)
1268
+
});
1269
+
1270
+
for (int k = 1; k < 3; k++)
1271
+
{
1272
+
int nestedId = currId * 1000 + k;
1273
+
data.Add(new Employee
1274
+
{
1275
+
Id = nestedId,
1276
+
ParentId = currId,
1277
+
Name = $"second level child {k} of {i} and {currId}",
1278
+
EmailAddress = $"{nestedId}@example.com",
1279
+
HireDate = DateTime.Now.AddMinutes(-nestedId)
1280
+
}); ;
1281
+
}
1282
+
}
1283
+
}
1284
+
1285
+
return await Task.FromResult(data);
1286
+
}
1287
+
}
1288
+
````
1289
+
1168
1290
### OnRowRender
1169
1291
1170
1292
This event fires upon the rendering of the TreeList rows. It receives an argument of type `TreeListRowRenderEventArgs` which exposes the following fields:
0 commit comments