Community & Support
Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > Beta Forum > Client-bound Grid in a Dock

Answered Client-bound Grid in a Dock

Feed from this thread
  • Posted on Mar 9, 2010 (permalink)

    Hi there,

    I have spent some time trying the Q1 2010 beta and I found something that applies to the current stable version - Q3 2009.

    I have a RadGrid in a RadDock. It has no width so it occupies 100% of the width of the dock as expected. When I drag the corresponding dock to another - wider dock zone, the content of the grid gets resized but the header row - does not resize accordingly. I guess it has something to do with paging.  I guess rebinding the grid when dropping the dock would work but that would be a very dirty solution.

    Is this a bug or actually a feature? From what I've learned so far client-bound grids behave very differently than server-bound ones...

    Best regards,
    Valery.

    Reply

  • Pero Pero admin's avatar

    Posted on Mar 11, 2010 (permalink)

    Hello Valery,

    I modified the following example from our online demos by placing the grid in a dock, and the head row is resized accordingly: http://demos.telerik.com/aspnet-ajax/grid/examples/clientbinding/defaultcs.aspx. I have attached the modified demo to the thread.

    Could you please provide more information on the issue? A sample source code would help us a lot.

    Regards,
    Pero
    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.
    Attached files

    Reply

  • Posted on Mar 11, 2010 (permalink)

    Hi Pero,

    It turned out that the bug is caused by the UseStaticHeaders property being enabled and the width of some columns fixed. I've submitted a ticket 289231. I've also attached a demo page.

    Thanks,
    Valery.

    Reply

  • Answer Pero Pero admin's avatar

    Posted on Mar 12, 2010 (permalink)

    Hello Valery,

    We have provided a solution to your problem in the respective support ticket, but I will also present the solution here so it is available to the community.

    Here it is:

    When used with static headers, RadGrid makes some adjustments to its layout. This action should be executed each time the control changes its size. In your case I suggest you to subscribe to the RadDock's OnClientDragEnd event:
    <%@ Page Language="C#" %>
    <%@ Import Namespace="System.Data" %>
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
      
    <script runat="server">
      
    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);
      
        object[] dataSource = new object[] { };
        RadGrid1.DataSource = dataSource;
        RadGrid1.DataBind();
    }
      
    </script>
      
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
      
    <head id="Head1" runat="server">
    <meta http-equiv="content-type" content="text/html;charset=utf-8" />
    <title>RadControls</title>
    </head>
    <body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" />
      
        <div style="height: 300px">
            <telerik:RadDockZone ID="RadDockZone1" runat="server" Height="100%" />
        </div>
        <telerik:RadDock ID="DockGrid" runat="server" OnClientDragEnd="repaintGrid">
            <ContentTemplate>
                <telerik:RadGrid ID="RadGrid1" runat="server">
                    <MasterTableView>
                        <Columns>
                            <telerik:GridBoundColumn HeaderText="ID" DataField="ID" HeaderStyle-Width="50px"
                                ItemStyle-Width="50px" />
                            <telerik:GridBoundColumn HeaderText="Text" DataField="Text" />
                            <telerik:GridBoundColumn HeaderText="Value" DataField="Value" DataFormatString="{0:N3}"
                                HeaderStyle-Width="50px" ItemStyle-Width="50px" />
                        </Columns>
                    </MasterTableView>
                    <ClientSettings>
                        <Scrolling AllowScroll="true" UseStaticHeaders="true" />
                    </ClientSettings>
                </telerik:RadGrid>
            </ContentTemplate>
        </telerik:RadDock>
      
        <script type="text/javascript">
            function getRandomString(length) {
                var chars = ' 0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz';
                var s = '';
                for (var i = 0; i < length; i++) {
                    var rnum = Math.floor(Math.random() * chars.length);
                    s += chars.substring(rnum, rnum + 1);
                }
      
                return s;
            }
      
            var dataItems = [];
            for (var i = 0; i < 100; i++) {
                var dataItem = {
                    ID: i,
                    Text: getRandomString(50),
                    Value: Math.random()
                };
      
                dataItems.push(dataItem);
            }
      
            function updateGrid(radGrid) {
                var masterTableView = radGrid.get_masterTableView();
      
                masterTableView.set_dataSource(dataItems);
                masterTableView.dataBind();
            }
      
            function OnGridCommand(radGrid, args) {
                updateGrid(radGrid);
            }
              
            function repaintGrid(sender, args)
            {
                var radGrid = $find('<%= RadGrid1.ClientID %>');
                radGrid.repaint();
            }
      
            Sys.Application.add_load(function() {
                var radGrid = $find('<%= RadGrid1.ClientID %>');
                radGrid.add_command(OnGridCommand);
      
                updateGrid(radGrid);
            });
        </script>
      
    </form>
    </body>
    </html>


    A more universal solution is to replace the repaintGrid method with the following:
    function repaintGrid(sender, args)
    {
         $telerik.repaintChildren(sender);
    }




    Best wishes,
    Pero
    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.

    Reply

  • Q1 Webinar Week

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > Beta Forum > Client-bound Grid in a Dock