We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Way to hide/show stacked headers based on some condition

Hi,

Is there a way to hide/show stacked headers in SfDataGrid based on some condition by user input in one of the Editable columns? Currently I can able to reset StackedHeaderRows collections to achieve hiding like below:

AdlDataGrid.StackedHeaderRows = new StackedHeaderRows();

and readding stacked columns when conditions met to show it back. Wondering if there is a better way to show/hide it.

3 Replies

GL Ganeshkumar Lingappan Syncfusion Team April 22, 2015 01:33 PM UTC

Hi Vasanth,

Thank you for Contacting Syncfusion support.

We have analyzed your query and you can achieve your requirement by changing the height for the StackedHeaderRows. To hide the StackedHeaderRow you have to set the height as zero and to Show the StackedHeaderRow you have to set the default height. We have prepared the sample to hide and show the StackedHeader based on Editing the Cell and it is attached in below mentioned location. Please Refer the below code-snippet.

void sfdatagrid_CurrentCellEndEdit(object sender, Syncfusion.UI.Xaml.Grid.CurrentCellEndEditEventArgs args)

{

//GetVisualContainer Helps to change the RowHeight value for the Stacked Header.

var visualcontainer = sfdatagrid.GetVisualContainer();

var grid = sender as SfDataGrid;

//GetRecordAtRowIndex helps to Get the Record value for the Particular RowIndex.

var rowData = grid.GetRecordAtRowIndex(args.RowColumnIndex.RowIndex);

//GetPropertyAccessProvider helps to get the Cell Value for the Particular column.

var celltext = grid.View.GetPropertyAccessProvider().GetValue(rowData, "ProductName");

if (celltext != null && celltext.Equals("HardWare"))

visualcontainer.RowHeights[0] = 0;

else

visualcontainer.RowHeights[0] = 45;

visualcontainer.InvalidateMeasure();

}

Sample Link : http://www.syncfusion.com/downloads/support/forum/118901/StackedHeaderRow102966953.zip

Please let us know if you require further assistance.

Regards,

Ganeshkumar




VA Vasanth April 22, 2015 02:13 PM UTC

perfect, thanks!!


SC Saranya CJ Syncfusion Team April 23, 2015 07:32 AM UTC

Hi Vasanth,

We are glad to know that your reported issue works at your end. Please let us know if you require further assistance.

Regards,
Saranya

Loader.
Live Chat Icon For mobile
Up arrow icon