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.
Unfortunately, activation email could not send to your email. Please try again.

GDBG visibility of plus/minus button for nested rows.

Thread ID:

Created:

Updated:

Platform:

Replies:

98719 Mar 22,2011 10:52 AM May 9,2011 11:36 PM Windows Forms 18
loading
Tags: GridControl
Alex Feldman
Asked On March 22, 2011 10:52 AM

Question about GridDataBoundGrid.
I'm using 'aGrid.Binder.AddRelation("NestedProperty");' to bind and see nested rows.

Plus button appear on grid for all rows. When click the button is removed if there is no nested rows.

Is there way to remove it when grid is initially displayed?

I have found similar topic for grouping grid:
http://www.syncfusion.com/support/forums/grid-windows/97916/Problem-with-empty-nested-tables
I think my question is about the same functionality but for GDBG.

Syncfusion v.9.1 is used.

Thank you.


Jisha Joy [Syncfusion]
Replied On March 25, 2011 03:25 AM

Hi Alex,

Thank you for using Syncfusion products.

You need to handle the QueryCellInfo event to achieve the desired behavior. Please refer to the code,

void Model_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)
{
//other codes
if (e.ColIndex == 1)
{
GridBoundRecordState state = this.gridDataBoundGrid1.Binder.GetRecordStateAtRowIndex(e.RowIndex);
if (state.HasChildList && state.ChildCount == 0)
{

e.Style.CellType = "Static";
e.Style.Enabled = false;
e.Style.Clickable = false;
e.Style.Text = "";
e.Style.BackColor = SystemColors.Control;

}
}
}

Regards,
Jisha


Alex Feldman
Replied On March 25, 2011 01:36 PM

Thank you, Jisha

Unfortunately the example doesn't work in my case: all rows pluses got hidden, even if row has nested rows.

I'm going to try to use my binding list structure to find out whether record has a "ChildCount > 0". It should work.
However if you know any other internal grid way to achive the result it would help.

Alex Feldman.


Jisha Joy [Syncfusion]
Replied On March 30, 2011 07:00 AM

Hi Alex,

Could you please provide us a sample showing the issue?.

Regards,
Jisha


Alex Feldman
Replied On March 30, 2011 12:09 PM

Hi Jisha,

I have attached the example.

Click the button on the top would assign DataSource to the grid.
The last row has nested row. If the code from your example disabled ("Model_QueryCellInfo") you can see the nested rows.

Thank you,
Alex Feldman.



pushButtonTest_72d06937.zip

Jisha Joy [Syncfusion]
Replied On March 31, 2011 04:42 AM

Hi Alex,


Please find the following modified code for QueryCellInfo to solve the issue,


private void Model_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)
{

if (e.ColIndex == 1)
{


GridBoundRecordState state = this.gridDataBoundGrid1.Binder.GetRecordStateAtRowIndex(e.RowIndex);
if (state !=null && state.HasChildList && state.ChildCount == 0)
{
int count;
if (state.Position >= state.Table.Count)
{
count = 0;
}
else
{
this.gridDataBoundGrid1.BeginUpdate();
this.gridDataBoundGrid1.ExpandAtRowIndex(e.RowIndex);
count = state.ChildCount;
this.gridDataBoundGrid1.CollapseAtRowIndex(e.RowIndex);
this.gridDataBoundGrid1.EndUpdate();
}

if (count == 0)
{
e.Style.CellType = "Static";
e.Style.Enabled = false;
e.Style.Clickable = false;
e.Style.Text = "";
e.Style.BackColor = SystemColors.Control;
}
}
}
}

Regards,
Jisha




Alex Feldman
Replied On March 31, 2011 09:21 AM

Thank you Jisha,
It works for the test case.
Unfortunately I could not use it, since it's broken if any of the column is sorted.
In my workaround I use
int pos = gdbView.Binder.RowIndexToListManagerPosition(e.RowIndex);
which return correct position in CurrencyManager.
But I don't know how to get correct GridBoundRecordState.
Could you help?
Thank you,
Alex Feldman.


Alex Feldman
Replied On March 31, 2011 09:33 AM

I have added SortableBindingList into my test project.
You can check the solution attached.



pushButtonTest2_db4c132c.zip

Jisha Joy [Syncfusion]
Replied On April 5, 2011 03:18 AM

Hi Alex,
To get the record index of the hierarchical GridDataBoundGrid from its absolute row index, you can make use of ‘RowIndexToListManagerPosition()’ method to achieve this. This method returns the zero based row index of the underlying data source.

//in CelldoubleClick event
void gridDataBoundGrid1_CellDoubleClick(object sender, GridCellClickEventArgs e)
{
int level = this.gridDataBoundGrid1.Binder.GetRecordStateAtRowIndex(e.RowIndex).LevelIndex;
int index = this.gridDataBoundGrid1.Binder.RowIndexToListManagerPosition(e.RowIndex);
MessageBox.Show("Level: " + level.ToString() + ", RecordIndex: " + index.ToString());
}

Regards,
Jisha


Alex Feldman
Replied On April 5, 2011 01:28 PM

Thank you, Jisha,

Can you please answer my original question?
How I can hide "plus" buttons in case there are no nested rows.

The code in your example does not work for sorted GDBG.

Thank you,
Alex Feldman.


Jisha Joy [Syncfusion]
Replied On April 11, 2011 02:04 AM


Hi ALex,

I have tested it in the following sample and unable to see the issue mentioned,

http://www.syncfusion.com/uploads/user/uploads/pushButtonTest_72d06937.zip

Regards,
Jisha


Alex Feldman
Replied On April 11, 2011 10:48 AM

Hi Jisha,

The example you attach reference the initial example, that doesn't work at all!

I have attached the latest example for you.

And here the steps to replicate the issue:

1. Click "button1". Binding is set.
2. Verify that record with ID=4 has nested rows: expand and than collapse the row.
3. Double click to the header of "ID" or "Name" column. Make sorting reverse, so record id=4 is the first row.

Plus button is not displayed in this case.
Could you please tell is there workaround for this?

Thank you,
Alex Feldman.




PlusButtonTest3_7a72668.zip

Jisha Joy [Syncfusion]
Replied On April 18, 2011 04:51 AM

Hi,

Please refer to the following sample that does not show +/- button for the row with no child records.

http://www.syncfusion.com/support/user/uploads/UpdatableCollectionBaseExpandGrid_c483b19.zip


Regards,
Jisha


Alex Feldman
Replied On April 18, 2011 09:03 AM

Salute Jisha,

Unfortunately, your example doesn't work.

I have performed the following steps in your example.
1. Delete all children of parentName0 using "Delete current row". (There were 2 children).
2. Sort "ParentName" by double clicking the header. Button is still displayed incorrectly for parenName0 row, when it resorted to be the last and the first again.

Less important but when sorting is performed, all rows are collapsing.

Could you please provide workaround?


Jisha Joy [Syncfusion]
Replied On April 28, 2011 07:41 AM

Hi Alex,

Sorry for the delay in getting back to you. We are currently working on this and will update you by tomorrow/.

Regards,
Jisha


Alex Feldman
Replied On May 3, 2011 10:55 AM

Thank you Jisha,
I'm waiting.
Alex Feldman.


Rajadurai C [Syncfusion]
Replied On May 9, 2011 04:56 AM

Hi Alex,

We regret for the delay in getting back to you.

To remove the plus/minus icon getting displayed after sorting for rows that doesn't have child rows, you can handle the following code in QueryCellInfo event.

if (e.RowIndex > this.gridDataBoundGrid1.Model.Rows.HeaderCount && e.ColIndex == 1)
{
GridBoundRecordState state = gridDataBoundGrid1.Binder.GetRecordStateAtRowIndex(e.RowIndex);
GridHierarchyLevel level = gridDataBoundGrid1.Binder.GetHierarchyLevel(state.LevelIndex);
IList list=null;
if(state.Table.Count > state.Position)
list = GetChildList(level.Relation, state.Table[state.Position]);
bool newHasChildList = list != null && list.Count > 0;
if (newHasChildList)
{
e.Style.CellType = "DataBoundRowExpandCell";
}
else
{
e.Style.CellType = "RowHeader";
e.Style.Text = string.Empty;
}
}


Here is the modified sample for your reference.
http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=UpdatableCollectionBaseExpandGrid_Modified-902323328.zip


To retain the expanded state after sorting applied, you would have to handle respective settings in the sample. Please find the sample below that achieves the same.
http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=SortExpanded12098648.zip


Regards,
Rajadurai


Alex Feldman
Replied On May 9, 2011 09:10 AM

Thank you Jisha!
Wow, it looks like it's working!


Rajadurai C [Syncfusion]
Replied On May 9, 2011 11:36 PM

Hi Alex,

Thanks for your update.

Regards,
Rajadurai


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;