This is related to a DevExpess XtraGrid's GridView.
I need to remove the drilldown plus icon (+)
from any MasterRow in a GridView that doesn't have any data for it's ChildRow.
Currently, all the rows (MasterRows) in my GridView display the drilldown plus icon (+)
. When the drilldown plus icon (+)
is clicked, the ChildRow is displayed with the appropriate data. But, if the ChildRow has no data, then the ChildRow is not displayed (expanded). I need to make the drilldown plus icon (+)
invisible so that the user doesn't see it if there is no data in the ChildRow.
I have a function that checks if data is available for the ChildRow, which then allows the ChildRow to display (expand) or not.
I have used GridView.OptionsView.ShowDetailButtons
but that hides the drilldown plus icons (+)
on all the rows. That doesn't work for me since I only need to hide it if there is no data for the ChildRow.
Here is the code that I have so far:
private void gridView1_MasterRowGetRelationCount(object sender, MasterRowGetRelationCountEventArgs e)
{
e.RelationCount = 1;
}
private void gridView1_MasterRowEmpty(object sender, MasterRowEmptyEventArgs e)
{
e.IsEmpty = IsRelationEmpty(e.RowHandle, e.RelationIndex);
}
bool IsRelationEmpty(int rowHandleX, int relationIndex)
{
Tuple<string, double, double> row = (Tuple<string, double, double>)gridView1.GetRow(rowHandleX);
return rowHandleX == DevExpress.XtraGrid.GridControl.InvalidRowHandle || _tfs._dataDictionary[row.Item1.ToString()].Item2.Count == 0;
}
private void gridView1_MasterRowGetChildList(object sender, MasterRowGetChildListEventArgs e)
{
if (IsRelationEmpty(e.RowHandle, e.RelationIndex))
{
return;
}
Tuple<string, double, double> row = (Tuple<string, double, double>)gridView1.GetRow(e.RowHandle);
e.ChildList = _tfs._dataDictionary[row.Item1.ToString()].Item2.ToList(); // _tfs.DictionaryToList();
}
private void gridView1_MasterRowGetRelationName(object sender, MasterRowGetRelationNameEventArgs e)
{
e.RelationName = "Work Items with no Size Estimate:";
}
Any direction or suggestions would be greatly appreciated.
Thanks in advance,
Marwan (^_^)
I suggest you to follow this DevExpress thread - How to hide disabled expand/collapse buttons for master rows without detail records
The XtraGrid does not provide an option to hide master-detail expand buttons for empty details. You can work around this limitation via the CustomDrawCell event.
Here is the necessary code:
private void gridView1_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e) {
GridView view = sender as GridView;
if(e.Column.VisibleIndex == 0 && view.IsMasterRowEmpty(e.RowHandle))
(e.Cell as GridCellInfo).CellButtonRect = Rectangle.Empty;
}
}
Hope this help..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With