mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-06-19 13:28:16 +08:00
Work done to allow user to update table cell. (#546)
This commit is contained in:

committed by
GitHub

parent
ad23855b0a
commit
e3dfe23b59
@ -189,6 +189,56 @@ namespace Spectre.Console
|
||||
return table;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates a tables cell.
|
||||
/// </summary>
|
||||
/// <param name="table">The table to update.</param>
|
||||
/// <param name="rowIndex">The index of row to update.</param>
|
||||
/// <param name="columnIndex">The index of column to update.</param>
|
||||
/// <param name="cellData">New cell data.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
public static Table UpdateCell(this Table table, int rowIndex, int columnIndex, IRenderable cellData)
|
||||
{
|
||||
if (table is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(table));
|
||||
}
|
||||
|
||||
if (cellData is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(cellData));
|
||||
}
|
||||
|
||||
table.Rows.Update(rowIndex, columnIndex, cellData);
|
||||
|
||||
return table;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates a tables cell.
|
||||
/// </summary>
|
||||
/// <param name="table">The table to update.</param>
|
||||
/// <param name="rowIndex">The index of row to update.</param>
|
||||
/// <param name="columnIndex">The index of column to update.</param>
|
||||
/// <param name="cellData">New cell data.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
public static Table UpdateCell(this Table table, int rowIndex, int columnIndex, string cellData)
|
||||
{
|
||||
if (table is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(table));
|
||||
}
|
||||
|
||||
if (cellData is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(cellData));
|
||||
}
|
||||
|
||||
table.Rows.Update(rowIndex, columnIndex, new Markup(cellData));
|
||||
|
||||
return table;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserts a row in the table at the specified index.
|
||||
/// </summary>
|
||||
|
Reference in New Issue
Block a user