How hide row based on a condition?

Hi

Can help me, How I can hide a row based on a condition in TreeGrid?


3 Replies 1 reply marked as answer

PK Padmavathy Kamalanathan Syncfusion Team June 9, 2021 02:17 PM UTC

Hi Jose, 
 
Thanks for contacting Syncfusion Forums. 
 
Query: How hide row based on a condition? 
 
You can customize the appearance of a row by using the RowDataBound event. The RowDataBound event triggers for every row. In the event handler, you can get the RowDataBoundEventArgs that contains details of the row. From args.Data you can get the row’s data and based on the row data, you can add class name to the row (args.Row) using “AddClass” method and you can set style “display” as “none” to the specific rows and hide them. 
 
Please check the below code snippet, 
 

<SfTreeGrid @ref="TreeGrid" DataSource="TreeData" IdMapping="TaskId" ParentIdMapping="ParentId" Height="315" TreeColumnIndex="1" > 
   <TreeGridEvents RowDataBound="OnRowDataBound" Value="WrapData"></TreeGridEvents> 
</SfTreeGrid> 
 
    public void OnRowDataBound(RowDataBoundEventArgs<WrapData> args) 
    { 
        if(args.Data.Priority == "Normal"){ //checking condition 
            args.Row.AddClass(new string[] { "hide" }); //adding class name to row 
        } 
    } 
 
<style> 
.hide{ 
    display: none; 
} 
</style> 


 
Please check the below help documentation, 
 
Kindly get back to us for further assistance. 
 
Regards, 
Padmavathy Kamalanathan 


Marked as answer

JL jose luis barajas June 9, 2021 06:47 PM UTC

Hi Padmavathy

Thanks, works perfect!




FS Farveen Sulthana Thameeztheen Basha Syncfusion Team June 10, 2021 08:52 AM UTC

Hi Jose,  

Thanks for your update. Please get back to us if you need any further assistance. We are happy to assist you. 

Regards, 
Farveen sulthana T 


Loader.
Up arrow icon