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

Selfhierarchy/Paging Issues when AllowPaging="True" and RecordSet Exceeds PageSize Value

8 Answers 176 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Matt
Top achievements
Rank 1
Matt asked on 10 Apr 2009, 09:44 PM
I have a radgrid that displays selfhierarchical records.  When I have the following set:

AllowPaging="False" 
AllowCustomPaging="False" 
EnableLinqExpressions="True" 
 
-OR- 
 
AllowPaging="False" 
AllowCustomPaging="True" 
EnableLinqExpressions="True" 

The hierarchy (regardless of how many levels) is displayed correctly and everything works as expected.  However, if I turn paging on as using AllowPaging="True", things start to fall apart in that the grid will display two levels of hierarcy for SOME records (when there should be three) and NONE for others (when there should be ONE).  In addition, if I have the detail records expanded for all visible parent nodes, some of the detail records aren't displayed until I change the number of results for that page (e.g., from 10 to 20) even though there are only five detail records (when it's set to 10, two are displayed, when I change it to 20, all five are displayed).  (This is being changed via the pager control and not via the PageSize setting.)

Here is the code for the radgrid.  The datasource is set when the user loads the page and is dynamic.  It is not set at markup time.

    <telerik:RadGrid  
        ID="grdNotes"  
        runat="server"  
        OnColumnCreated="grdNotes_ColumnCreated" 
        OnItemCreated="grdNotes_ItemCreated"  
        OnItemDataBound="grdNotes_ItemDataBound" 
        OnNeedDataSource="grdNotes_NeedDataSource" 
        AutoGenerateColumns="False" 
        AllowPaging="True"  
        AllowCustomPaging="True"  
        ShowStatusBar="True"  
        EnableLinqExpressions="True" PageSize="10"
        > 
         
        <HeaderContextMenu  
            EnableTheming="True"
            <CollapseAnimation  
                Type="OutQuint"  
                Duration="200"
            </CollapseAnimation> 
        </HeaderContextMenu> 
         
        <ClientSettings > 
            <Selecting AllowRowSelect="True" /> 
            <ClientEvents  
                OnRowCreated="RowCreated"  
                OnRowSelected="RowSelected"  
                OnRowDblClick="grdNotes_OnRowDblClick"
            </ClientEvents> 
        </ClientSettings> 
         
        <PagerStyle  
            HorizontalAlign="Center"  
            Position="Bottom" 
            AlwaysVisible="True" 
            Mode="NextPrevAndNumeric" 
            Wrap="False" 
            BackColor="White"  
            Font-Size="Large" 
        />          
                 
        <MasterTableView  
            HierarchyDefaultExpanded="true"  
            HierarchyLoadMode="Client"  
            AllowSorting="true" 
            DataKeyNames="Id,ParentId"  
            ClientDataKeyNames="Id,ParentId" 
            Width="100%" 
            AutoGenerateColumns="false" 
            ShowHeader="true" 
            NoDetailRecordsText=""  
            enablenorecordstemplate="False" 
            > 
 
            <SelfHierarchySettings  
                ParentKeyName="ParentId"  
                KeyName="Id"  
                MaximumDepth="20" /> 
                                 
            <RowIndicatorColumn> 
                <HeaderStyle Width="20px"></HeaderStyle> 
            </RowIndicatorColumn> 
 
            <ExpandCollapseColumn visible="True"
                <HeaderStyle Width="20px"></HeaderStyle> 
            </ExpandCollapseColumn> 
                 
            <Columns> 
                <telerik:GridBoundColumn DataField="Id" HeaderText="Id" SortExpression="Id" UniqueName="Id" ReadOnly="True"
                </telerik:GridBoundColumn> 
                <telerik:GridBoundColumn DataField="Title" HeaderText="Title" SortExpression="Title" UniqueName="Title"
                </telerik:GridBoundColumn> 
                <telerik:GridBoundColumn DataField="Body" HeaderText="Body" SortExpression="Body" UniqueName="Body"
                </telerik:GridBoundColumn> 
                <telerik:GridBoundColumn DataField="CreatedBy" HeaderText="Created By" SortExpression="CreatedBy" UniqueName="CreatedBy"
                </telerik:GridBoundColumn> 
                <telerik:GridBoundColumn DataField="CreatedDate" HeaderText="Created On" SortExpression="CreatedDate" UniqueName="CreatedOn"
                </telerik:GridBoundColumn> 
                <telerik:GridBoundColumn DataField="ModifiedDate" HeaderText="Modified On" SortExpression="ModifiedDate" UniqueName="ModifiedOn"
                </telerik:GridBoundColumn> 
                <telerik:GridBoundColumn DataField="ParentId" HeaderText="Parent Id" SortExpression="ParentId" UniqueName="ParentId" visible="false"
                </telerik:GridBoundColumn> 
            </Columns>                 
        </MasterTableView> 
 
        <FilterMenu EnableTheming="True"
            <CollapseAnimation  
                Type="OutQuint"  
                Duration="200"
            </CollapseAnimation> 
        </FilterMenu> 
    </telerik:RadGrid>  

Here's the code behind refreshing the datasource:

protected void grdNotes_NeedDataSource(object source, GridNeedDataSourceEventArgs e) 
            RefreshGridDataSource(); 
 
private void RefreshGridDataSource() 
            NoteDataProvider noteDataProvider = new NoteDataProvider(WebServicesUri, TicketIdentity.Current.Ticket); 
 
            List<DisplayNote> displayNotes = noteDataProvider.GetAll(ObjectId); 
 
            grdNotes.DataSource = displayNotes; 
            grdNotes.VirtualItemCount = displayNotes.Count; 
 

Here's the kicker...when I set PageSize=50 (from the default of 10), all records (there are 24 that I'm working with) appear to show up correctly -- on the all three levels that I'm expecting.  When I set PageSize=20 and then run it, I get the same issues as when I set it to 10, only less so. 

With that in mind, I believe there's an issue with paging and hierarchy when the number of TOTAL records in the datasource exceeds the PageSize, regardless of where they are in the hierarchy level.

Is this a known issue or is there something I'm missing that's causing me to experience this wackiness?  We are using the latest release (2009 Q1) FWIW.

8 Answers, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 13 Apr 2009, 03:10 PM
Hello Matt,

Please, try setting EnableLinqExpressions = false and let us know of the result.

All the best,
Tsvetoslav
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Matt
Top achievements
Rank 1
answered on 14 Apr 2009, 12:10 PM
I already tried setting EnableLinqExpressions=false in my previous attempts, but the result was the same (e.g., incorrect).  In addition to the issues detailed above, I also encounter second/third tier records appearing on the first tier (when EnableLinqExpressions=false is set).

For example, instead of the expected result of:

→ 2 
→ 3 
    â†’ 4 
    â†’ 5 
→ 7 
10 
→ 11 
    â†’ 12 
    â†’ 13 
14 
→ 15 


I get the following:

→ 2 
→ 3 
    â†’ 4 
    â†’ 5 
→ 7 
10 
→ 11 
11 
    â†’ 12 
    â†’ 13 
12 
13 
14 
→ 15 
15 

ONLY when I set AllowPaging="False"  and EnableLinqExpressions="True" am I able to get the result I expect to see.
0
Tsvetoslav
Telerik team
answered on 16 Apr 2009, 01:39 PM
Hi Matt,

With the .NET 3.5 build of RadGrid for ASP.NET AJAX and LINQ filter expressions enabled (EnableLinqExpressions = true), the filter expressions set for the grid either internally by its filtering mechanism or manually in code should conform to the LINQ expression syntax instead of the old T-SQL syntax. Only thus they will be evaluated properly by the control. Here you can find further information on this matter.

Here is a code snippet which showing how to apply proper LINQ expression syntax:

public void Page_Load(object sender, EventArgs e)    
       {    
           if (Assembly.GetAssembly(typeof(ScriptManager)).FullName.IndexOf("3.5") != -1)    
           {    
               RadGrid1.MasterTableView.FilterExpression = @"it[""ReportsTo""] = Convert.DBNull";    
           }    
           else    
           {    
               RadGrid1.MasterTableView.FilterExpression = "ReportsTo IS NULL";    
           }    
       }    
 


Other than that I could not reproduce the problem with linq expressions switched off.

Please, review the attached sample for comparison with your scenario.

Thank you.

Best Regards,
Tsvetoslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Matt
Top achievements
Rank 1
answered on 17 Apr 2009, 11:54 AM
I already took that into consideration (based on what I read in the online demo on self-hierarchy).  Here's what I've got in my Page_Load() method:

            if (!IsPostBack) 
            { 
                if (Assembly.GetAssembly(typeof(ScriptManager)).FullName.IndexOf("3.5") != -1) 
                { 
                    grdNotes.MasterTableView.FilterExpression = @"it.ParentId = 0";    //Convert.DBNull 
                } 
                else 
                { 
                    grdNotes.MasterTableView.FilterExpression = "ParentId = 0"// "ParentId IS NULL"; 
                } 
 
                RefreshGridDataSource(); 

Since ParentId will always be defined (the value is set to 0 if it's NULL in the database), I check to see if it's 0 vs. NULL.

Does it matter that I'm using a populated object (e.g., DisplayNote, as previously identified in the previous reply) as the datasource vs. a SQL statement that's then executed?  Are there any special characteristics that need to be taken into consideration when doing that?
0
Tsvetoslav
Telerik team
answered on 21 Apr 2009, 10:37 AM
Hi Matt,

Excuse me for having missed to send the sample.

Binding to a collection of custom objects should make no difference.

Best Regards,
Tsvetoslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
zxp
Top achievements
Rank 1
answered on 28 Feb 2011, 10:03 AM
I have the same problem with version 2010.3.1215.40. 

I have tried set EnableLinqExpressions=false, but that makes thing worse. All child items are displayed in as a root item, hence there are lots of duplicate items.

If I set the pageSize big enough to show all the items in one page, then everything works fine. 
Can anyone help me on this? Thanks very very much!
0
zxp
Top achievements
Rank 1
answered on 28 Feb 2011, 10:15 AM
I uploaded two screen shots. 
NoChild.png is what the problem is now, if I set the pageSize to 15.
WithoutPaging.png works fine, as I change the pageSize to 25 to display all the items in one page.
0
Tsvetoslav
Telerik team
answered on 02 Mar 2011, 10:03 AM
Hello,

When disabling linq expressions, your initial filter condition should change so that not all child items but only the root one be displayed. Take a look at our online example, how it is done in the on Page_Load event:
Copy Code
public void Page_Load(object sender, EventArgs e)
{
if (Assembly.GetAssembly(typeof(ScriptManager)).FullName.IndexOf("3.5") != -1 || Assembly.GetAssembly(typeof(ScriptManager)).FullName.IndexOf("4.0") != -1)
{
RadGrid1.MasterTableView.FilterExpression = @"it[""ReportsTo""] = Convert.DBNull";
}
else
{
RadGrid1.MasterTableView.FilterExpression = "ReportsTo IS NULL";
}
}

The else branch of the condition is the one you want to implement, of course, reworking it accordingly for the field you have.

Hope it helps.

Regards,
Tsvetoslav
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
Grid
Asked by
Matt
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Matt
Top achievements
Rank 1
zxp
Top achievements
Rank 1
Share this question
or