Hi Yunus,
Query: I need to disable deselecting rows by Esc
key. Can you help to achieve this please? . after using Escape key
if I deselect by mouse click, then all rows get cleared again.
Based on your query, we
understand that you want to disable the deselection of rows using the Escape
key and maintaining the row selection on mouse click. When a row is deselected
using the mouse click, all selected rows will be cleared, which is the behavior.
We have achieved this requirement
by using the checkbox selection feature of the treegrid and preventing row
deselection(while pressing Esc Key) using the RowDeselecting event of the
treegrid.
Please refer to the below code
snippet,
<SfTreeGrid DataSource="TreeData" IdMapping="TaskID" ParentIdMapping="ParentID" TreeColumnIndex="2" Height="326">
<TreeGridSelectionSettings PersistSelection="true" CheckboxOnly="true"></TreeGridSelectionSettings>
<TreeGridEvents RowDeselecting="rowdeselecting" TValue="SelfReferenceData"></TreeGridEvents>
<TreeGridColumns>
<TreeGridColumn Type="Syncfusion.Blazor.Grids.ColumnType.CheckBox" Width="50"></TreeGridColumn>
…
</TreeGridColumns>
</SfTreeGrid>
public void rowdeselecting(RowDeselectEventArgs<SelfReferenceData> args)
{
if (args.Event == null )
{
args.Cancel = true;
}
|
Please refer to the below demo,
https://blazor.syncfusion.com/demos/tree-grid/checkbox-selection?theme=bootstrap5
Please refer to the below help
documentation,
https://blazor.syncfusion.com/documentation/treegrid/selection#checkbox-selection
Kindly get back to us for further
assistance.
Regards,
Pon selva
If this post is
helpful, please consider Accepting it as the solution so that other members can
locate it more quickly.