This is a migrated thread and some comments may be shown as answers.

Self referencing grid issues

2 Answers 104 Views
Grid
This is a migrated thread and some comments may be shown as answers.
<><
Top achievements
Rank 1
<>< asked on 02 Jun 2011, 04:23 PM
Hi,

Following your Online Example for Grid/Self-referencing Hierarchy, I can get the self-referencing to work on my test project...but, the issues I am having are:

I am using Linq to Sql Classes  as my structure.

1. In my case, I set the root level filter to RadGrid1.MasterTableView.FilterExpression = "parentid = 0"This works as expected and only displays root level items, BUT, it never shows any children items b/c they are filtered out b/c of the filter expression.  If I do not set the filter, I can expand the parent items to see the child items, but, the child items also appear as root items since there is no root level filter.

2. This is related to issue 1, when fitlering items at the root level, it never shows/filters any child items, again, b/c of the above filter where it is only showing items where parentid = 0..thus, the linq to sql expression only returns items where parentid = 0.

3. If I do not set the filter condition (which then allows me to see the hierarchal structure) and I filter items, is it possible to always show the parent row if the item itself is supposed to be a child item?  For example, if the filter matches a child item, I want it to show the entire hierarchy of its parents even tho the parent might not match the filter condition.

Now, If I use a Parent-Child table structure, and not Self-Referencing is the following possible:

1.  When filtering on a child table, it only filters the items under the currently expanded parent.  Can I filter/show only parent items  (along w/ child items) which child tables that match my filter criteria?

---

Also, how does the paging work w/ self-referencing..ie, if only displaying 25 items per page, will it grab all child items for all the root level items?

On a side note, we are currently on version 2010.3.1215.40 of the RadControls for ASP.NET AJAX, so please let me know if there were known issues for the past version.

Thanks

2 Answers, 1 is accepted

Sort by
0
<><
Top achievements
Rank 1
answered on 02 Jun 2011, 05:26 PM
Hi,

Ok, so for #1 the issue seems to be with the following dynamic linq I was using to only return required results, commenting it out the self-referencing started to work as expected..but now, my question...if I have 1 million rows, it will have to return all rows for the self referencing to work correctly as I cannot only return the items I need to be displayed?

Protected Sub RadGrid1_NeedDataSource(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource
    Dim db As New TrackerDataContext
    db.Log = New System.Diagnostics.DebuggerWriter
    Dim query = From p In db.posts
                Select p
    'If String.IsNullOrWhiteSpace(RadGrid1.MasterTableView.FilterExpression) = False Then
    '    query = query.Where(RadGrid1.MasterTableView.FilterExpression)
    'End If
    'For Each exp As GridSortExpression In RadGrid1.MasterTableView.SortExpressions
    '    query = query.OrderBy(String.Format("{0} {1}", exp.FieldName, exp.SortOrder.ToString))
    'Next
    Dim start As Integer = RadGrid1.CurrentPageIndex * RadGrid1.PageSize
    Dim max As Integer = RadGrid1.PageSize
    RadGrid1.AllowCustomPaging = True
    'we always need count
    RadGrid1.VirtualItemCount = query.Count
    If isGrouping Or RadGrid1.MasterTableView.GroupByExpressions.Count > 0 Then
        start = 0
        max = RadGrid1.VirtualItemCount
        RadGrid1.AllowCustomPaging = False
    End If
    RadGrid1.DataSource = query.Skip(start).Take(max)
End Sub

So how can I handle custom paging/filtering/sorting while using self-referencing?

Also, now, if on the grid I select "NoFilter" for any column, it clears out the filter condition I had placed in the page_load event: RadGrid1.MasterTableView.FilterExpression = "post_parentid=0"

Also, please respond to item #3 and #1 under a parent-child table structure.

Take Care
0
Iana Tsolova
Telerik team
answered on 08 Jun 2011, 10:14 AM
Hello,

With the self-reference grid you should pass the whole datasource to the grid so it builds the hierarchy. And you definitely need the filter expression on Page_Load.
If you enabled filtering for the self-reference grid you can add the initial filter expression on Page_Load. Then to ensure that this expression is not cleared when you choose "No Filter" for some of the columns, in the NeedDataSource event handler, you can check what is the grid FilterExpression. And if it is equal to empty string, reassign it to the initial filter expression.
Additionally, when you use the grid built-in filtering, only the data in the current GridTableView is filtered. Therefore you should apply the filters for each nested table view separately.

Regards,
Iana
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Grid
Asked by
<><
Top achievements
Rank 1
Answers by
<><
Top achievements
Rank 1
Iana Tsolova
Telerik team
Share this question
or