Articles in this section
Category / Section

How to customize a cell in ASP.NET MVC TreeGrid?

1 min read

In ASP.NET MVC TreeGrid, the customization of grid cells can be done by using QueryCellInfo client-side event. This event is triggered at load time of the control. User will get cell values, cell element, columns and the record value in the function argument. With those information, we can customize that cell at load time.

 

The below code snippet explains how to highlight a cell of a duration field.

 

MVC

@(Html.EJ().TreeGrid("TreeGridContainer")      
// ...                    
.ClientSideEvents(eve =>
{ 
eve.QueryCellInfo("queryCellInfo");
})
.Datasource(ViewBag.datasource)                                             
// ...
)   
function queryCellInfo(args) {
if (args.column.field == "Duration") {
var cellValue = args.data.item.Duration;
if (cellValue < 5)
args.cellElement.bgColor = "#FA7F7F";
}
}
 

 

Highlight the cell of duration field based on condition In ASP.NET MVC TreeGrid

A sample with customized cell with condition is available in the following link,

Sample

 

 

Conclusion

I hope you enjoyed learning about how to customize a cell in ASP.NET MVC TreeGrid.

You can refer to our  ASP.NET MVC TreeGrid feature tour page to know about its other groundbreaking feature representations. You can also explore our  ASP.NET MVC TreeGrid examples to understand how to present and manipulate data.

For current customers, you can check out our ASP.NET MVC Controls from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our ASP.NET MVC TreeGrid and other ASP.NET MVC controls.

If you have any queries or require clarifications, please let us know in comments below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied