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

Search in hierarchical GridDataBoundGrid

Hi,
i've a GridDataBoundGrid which is bound to a dataset with hierachical data. In this grid I want to search for an expression in a one column. The search is done over the list which I can access over the currencymanager of the different levels.

Here's my code snippet:

for (int i = 0; i < this.Binder.HierarchyLevelCount; i++)
{
if (i==0)
cm = this.BindingContext[this.DataSource, this.DataMember] as CurrencyManager;
else
cm = this.BindingContext[this.DataSource, "level"+i] as CurrencyManager;
if (cm == null ||!(cm.List is DataView))
break;
dv = cm.List as DataView;
for (int row = 0; row < cm.Count; ++row)
{
s = dv[row][field].ToString();
if (s.Length > 0 && s.ToLower().Equals(pSearchString.ToLower()))
{
found = row;
break;
}
}
if (found > -1)
{
//Schauen, ob aktuelle Ebene schon aufgeklappt
//-->Zuerst alle Vorgänger selektieren und aufklappen lassen
if (i > 0 && dv[found].Row["vid"] != null)
this.SearchAndSelect(dv[found].Row["vid"].ToString(), "id");

this.Model.BeginUpdate();
//es wird davon ausgegangen, dass CurrentCell auf der ParentRow steht
//this.Binder.ListManagerPositionToRowIndex
found = this.Binder.PositionToRowIndex(found) + (i > 0 ? this.CurrentCell.RowIndex : 0);
this.CollapseAtRowIndex(found);
this.ExpandAtRowIndex(found);
this.CollapseAtRowIndex(found);
this.ExpandAtRowIndex(found);
this.Model.EndUpdate();

this.CurrentCell.MoveTo(found, pGridRange.Left, GridSetCurrentCellOptions.ScrollInView);
this.Selections.Clear();
this.Selections.Add(GridRangeInfo.Row(found));
break;
}
}

Now my problem is, that I should have the rowindex in the grid for the corresponding index of the list to mark this row. I've tried both 'Binder.ListManagerPositionToRowIndex' and 'this.Binder.PositionToRowIndex' but both functions are only working for the first level. I'm also trying to do a recursive search so that I can use the rowindex of the parent row, but it still can't get the right index if I'm searching for elements which are not in the first branch and are on deeper levels.

Regards,
Christian

7 Replies

HA haneefm Syncfusion Team July 12, 2007 06:06 PM UTC

Hi Christian,

Below is a forum thread that discuss with similar issue.
http://www.syncfusion.com/support/Forums/message.aspx?&MessageID=27312

Best regards,
Haneef


FA Faulhaber July 13, 2007 08:26 AM UTC

Hi Haneef,
the sample does not solve my problem, I've already tried the function 'ListManagerPositionToRowIndex', and it doesn't give me the right index for levels > 1. And the function .Binder.GetHierarchyLevel(0).FieldToRowField(field,rowOffset) always returns 0 for rowOffset (I suppose because I don't have multirow records).

I should have a function which gives me the grid-rowindex for a child e.g. of level3 for the corresponding index of the list for the complete level3 (not all entries in this list of level3 are childs of one parent).

Regards,
Christian

>Hi Christian,

Below is a forum thread that discuss with similar issue.
http://www.syncfusion.com/support/Forums/message.aspx?&MessageID=27312

Best regards,
Haneef


HA haneefm Syncfusion Team July 13, 2007 07:57 PM UTC

Hi Christian,

I am not sure of what be might be causing this strange behavior without a working sample. I have tested this issue in browser sample with Essentail studio V.4.x/5.x. But i was not able to reproduce the issue. Is it possible for you to upload us a minimal sample or modify the browser sample to reproduce the issue here? This will help us to analyse the issue further.

Best regards,
Haneef


FA Faulhaber July 16, 2007 01:58 PM UTC

Hi Haneef,
I found a workaround to get the index, so if I won't find any errors in it, it's ok for me.

Now I'm facing another problem with my hierarchical data and sorting. In my grid only the headerrow for the topmost data (datatable) is visible. As the schema for the lower levels are identical with the topmost datatable, I want to sort all data of all levels when the user doubleclicks a header column. Therefore I'm looping over the relations and get the DataView from the corresponding CurrencyManager of that level. Then I set the Sort-column and I can see in debugging that the DataView get sorted (at each level). In the grid however only the topmost level gets sorted but not child lists.
Do I have to call a special function e.g. Reset or Refresh, so that the sorting of the deeper levels are getting applied also?

Regards,
Christian


HA haneefm Syncfusion Team July 16, 2007 08:21 PM UTC

Hi Christian,

In GridDataBoundGrid, you need to handle the sorting of hierarchical data yourself. Please refer to the following link for more details on sorting hierarchy data in GridDataBoundGrid.

Forum 1: http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=15603.
Forum 2 : http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=9239.

Best regards,
Haneef


FA Faulhaber July 17, 2007 08:53 AM UTC

Hi Haneef,
thank you for the two links, I could apply it on my grid and it's working fine.
Perfect!

Regards,
Christian

>Hi Christian,

In GridDataBoundGrid, you need to handle the sorting of hierarchical data yourself. Please refer to the following link for more details on sorting hierarchy data in GridDataBoundGrid.

Forum 1: http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=15603.
Forum 2 : http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=9239.

Best regards,
Haneef


FA Faulhaber July 17, 2007 09:10 AM UTC

Hi Haneef,
thank you for the two links, I could apply it on my grid and it's working fine.
Perfect!

Regards,
Christian

>Hi Christian,

In GridDataBoundGrid, you need to handle the sorting of hierarchical data yourself. Please refer to the following link for more details on sorting hierarchy data in GridDataBoundGrid.

Forum 1: http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=15603.
Forum 2 : http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=9239.

Best regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon