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

RadGrid Layout Listview not working fine

6 Answers 86 Views
Grid
This is a migrated thread and some comments may be shown as answers.
li zhe
Top achievements
Rank 1
li zhe asked on 15 Aug 2010, 03:07 PM
Hello Admin

     I  downloaded Q2 2010 (version 2010.2.713)  demo version.  I created Layout listview like http://demos.telerik.com/aspnet-ajax/grid/examples/programming/listview/defaultcs.aspx .  it's working fine. but When I set EnableSEOPaging=true, the layout will not working. when I clicked next page or numeric page. the layout not correct.

    I need your help. maybe it's bug.

   I will waiting for your reply. Thank you

6 Answers, 1 is accepted

Sort by
0
li zhe
Top achievements
Rank 1
answered on 16 Aug 2010, 03:05 PM
I'm Waiting......
0
Dimo
Telerik team
answered on 17 Aug 2010, 07:45 AM
Hello Li Zhe,

When using SEO paging, the RadGrid rebinds itself in PreRender in order to change its page index, according to the query string. This happens after RadGrid_PreRender, which is used to inject some <table> tags in the control's HTML output, so the injected tags are lost. In your case, please use Page_PreRenderComplete instead:

protected void Page_PreRenderComplete(object sender, EventArgs e)
{
    int itemCount = RadGrid1.MasterTableView.GetItems(GridItemType.Item).Length + RadGrid1.MasterTableView.GetItems(GridItemType.AlternatingItem).Length;
    foreach (GridItem item in RadGrid1.Items)
    {
        if (item is GridDataItem && item.ItemIndex < itemCount - 1)
        {
            ((item as GridDataItem)["CustomerID"] as TableCell).Controls.Add(new LiteralControl("<table style='display:none;'><tr><td>"));
        }
    }
}


Kind regards,
Dimo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
li zhe
Top achievements
Rank 1
answered on 19 Aug 2010, 03:56 PM
Hello Dimo

       The problem still exist. I used vb.net. The following is aspx page. I change OnPreRender to " OnPreRender="RadGrid1_PreRenderComplete" "

    
<telerik:RadGrid ID="RadGrid1" DataSourceID="SqlDataSource1" AllowFilteringByColumn="true"
         runat="server" GridLines="None" AllowPaging="true" AllowSorting="true" OnPreRender="RadGrid1_PreRenderComplete"
         PageSize="15"  MasterTableView-ShowHeader="false" Width=100%>

        The following is code page:

Protected Sub RadGrid1_PreRenderComplete(ByVal sender As Object, ByVal e As System.EventArgs)
    Dim itemCount As Integer = TryCast(sender, RadGrid).MasterTableView.GetItems(GridItemType.Item).Length + TryCast(sender, RadGrid).MasterTableView.GetItems(GridItemType.AlternatingItem).Length
    For Each item As GridItem In TryCast(sender, RadGrid).Items
        If TypeOf item Is GridDataItem AndAlso item.ItemIndex < itemCount - 1 Then
            TryCast(TryCast(item, GridDataItem)("CustomerID"), TableCell).Controls.Add(New LiteralControl("<table style='display:none;'><tr><td>"))
        End If
    Next
End Sub

Is it right? but the layout still not correct When I clicked next page or numeric page.

I will waiting for your reply

Thank you
0
Dimo
Telerik team
answered on 19 Aug 2010, 04:17 PM
Hi Li Zhe,

Please mind the difference between the RadGrid's PreRender event and the Page's PreRenderComplete event. The latter occurs after the former, that's why you need to use it.

Dimo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
li zhe
Top achievements
Rank 1
answered on 20 Aug 2010, 03:59 AM
Hi Dimo

    Thank you for reply my post. it's my mistake for last post. I used following code now.but the layout still not correct When I clicked next page or numeric page.

  
Protected Sub Page_PreRenderComplete(ByVal sender As Object, ByVal e As System.EventArgs)
    Dim itemCount As Integer = TryCast(sender, RadGrid).MasterTableView.GetItems(GridItemType.Item).Length + TryCast(sender, RadGrid).MasterTableView.GetItems(GridItemType.AlternatingItem).Length
    For Each item As GridItem In TryCast(sender, RadGrid).Items
        If TypeOf item Is GridDataItem AndAlso item.ItemIndex < itemCount - 1 Then
            TryCast(TryCast(item, GridDataItem)("wholesale_id"), TableCell).Controls.Add(New LiteralControl("<table style='display:none;'><tr><td>"))
        End If
    Next
End Sub

The following is aspx page

<telerik:RadGrid ID="RadGrid1" DataSourceID="SqlDataSource1"
            runat="server" GridLines="None" AllowPaging="true" AllowSorting="true" PageSize="15"  MasterTableView-ShowHeader="false" Width=630px BackColor=white>
            <PagerStyle Mode="NextPrevAndNumeric" EnableSEOPaging=true />
            <MasterTableView TableLayout="Fixed">
                <ItemTemplate>
                    <%#IIf(Not CType(Container, GridItem).ItemIndex = 0, "</td></tr></table>", "")%>
                     
                    <asp:Panel ID="ItemContainer" CssClass='<%# IIf(CType(Container, GridItem).ItemType = GridItemType.Item, "item", "alternatingItem") %>'
                        runat="server">
                         
                        <font color=black><%#Eval("wholesale_retail")%></font><br />
                         
  
                    </asp:Panel>
                  
                </ItemTemplate>
                  
            </MasterTableView>
             
        </telerik:RadGrid>

the following is css style

.item, .alternatingItem
{
   float: left;
   padding: 15px;
   margin: 5px;
   width: 160px;
   height: 160px;
   border: 0px;
   
}
.item
{
   background: white !important;
}
.alternatingItem
{
   background: white !important;
}
.item:hover, .alternatingItem:hover
{
   background: white !important;
}


I will waiting for your reply . Thank you
0
Dimo
Telerik team
answered on 20 Aug 2010, 06:47 AM
Hello Li Zhe,

Please attach a debugger to your Page_PreRenderComplete method and check if it is executed. If not, this means that AutoEventWireUp is set to "false" for the page and you have to add a Handles clause to the method declaration in order to make it execute. If you are new to VB programming, please refer to:

http://msdn.microsoft.com/en-us/library/6w2tb12s.aspx


Dimo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
li zhe
Top achievements
Rank 1
Answers by
li zhe
Top achievements
Rank 1
Dimo
Telerik team
Share this question
or