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

GridTemplateColumn problem on page resize

4 Answers 57 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Arthur Rogers
Top achievements
Rank 1
Arthur Rogers asked on 01 Sep 2009, 01:36 PM

I encountered a problem with my clientbound grid. The markup is shown below. The grid successfully generates a default pagesize of 10 rows. As you can see the first column is a Template column showing a linkbutton. All 10 rows initially contain the corect data in the linkbutton column.
The problem is that when I increase the page size from 10 to say 20 at runtime the template column does not generate any content for the rows beyond the initial first 10. Everything else is present and accounted for (i.e. rows 11 to 20 are complete in every other column) but only the original 10 links will appear. Links 11 to 20 are blank. I've checked the RadGrid1_RowDataBound() event and it's correctly firing 20 times when the page size is incresed to 20 so the problems not there.

<telerik:RadGrid ID="RadGrid1" runat="server" AllowFilteringByColumn="True" AllowPaging="True"
    AllowSorting="True" AutoGenerateColumns="False" GridLines="None">
    <mastertableview ClientDataKeyNames="EquipID">
        <PagerStyle Mode="NumericPages" />
        <Columns>
            <telerik:GridTemplateColumn HeaderText="EquipID" SortExpression="EquipID" DataField="EquipID" DataType="System.Int32">
                <ItemTemplate>
                    <asp:linkbutton ID="lnkEquipID" NavigateUrl="#" runat="server"></asp:linkbutton>
                </ItemTemplate>
            </telerik:GridTemplateColumn>            
            <telerik:GridBoundColumn DataField="OrgID" HeaderText="OrgID" DataType="System.Int32"
                Visible="false">
            </telerik:GridBoundColumn>

           ... rest of GridBoundColumns ...
           
               <clientsettings allowcolumnsreorder="True" reordercolumnsonclient="True" databinding-enablecaching="false" EnableRowHoverStyle="true">
        <Selecting AllowRowSelect="True" />
        <DataBinding SelectMethod="GetDataAndCount" Location="https://localhost/MyService/MyService.svc"
            SortParameterType="Linq" FilterParameterType="Linq">
        </DataBinding>
        <Selecting AllowRowSelect="True" />
        <ClientEvents OnRowContextMenu="RowContextMenu" OnDataBinding="RadGrid1_DataBinding" OnRowDataBound="RadGrid1_RowDataBound" />
    </clientsettings>
</telerik:RadGrid>


Any idies. As always any help would be appreciated.

4 Answers, 1 is accepted

Sort by
0
Arthur Rogers
Top achievements
Rank 1
answered on 02 Sep 2009, 08:55 PM
The sheer volume of responses on this one is seriously making me nervous about implementing any kind of solution with Tekerik in the future. This is really a problem!!
In case I haven't described the problem well enough I'll can forward screenshots which really highlight the issue better than words.


0
BaiH
Top achievements
Rank 1
answered on 03 Sep 2009, 06:57 AM
Actually this is a known limitation of the grid when used with client binding mode. As you may be guessing your controls which are in the template column cannot be created on the client very easy. Therefore I think they are creating the templates on the server but only for the current page size.
When I'm implementing scenario like yours I inject the missing control on a fly from the RowDataBound event. You may check this example for how to get the cell from the the event handler.

--BH
0
Arthur Rogers
Top achievements
Rank 1
answered on 28 Sep 2009, 03:36 PM
BH,

I had to shelve this issue at the time because of time limitations. I just returning to it now. Thanks for replying.
I tried what you've indicated but I still stuck as to how this can be implemented.
According to the sample you pointed me to, the way to get a reference to a cell is...
args.get_item().get_cell("ColumnName")
This seems to work for GridBoundColumns but for GridTemplateColumns the above line returns null.

Here's a snippet from my grid

        <Columns>
            <telerik:GridTemplateColumn HeaderText="EquipID" Visible="true" SortExpression="EquipID" DataField="EquipID" DataType="System.Int32">
                <ItemTemplate>
                    <asp:ImageButton ID="imgbtnEquipID" ImageUrl="~/Images/spacer.gif" PostBackUrl="#" runat="server" Visible="true" />
                </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridBoundColumn DataField="ProjectName" HeaderText="ProjectName" DataType="System.String">
            </telerik:GridBoundColumn>
            .....
        </Columns>

As I said above I can get a reference to args.get_item().get_cell("ProjectName") but not args.get_item().get_cell("EquipID").
Am I doing something worng here?
Secondly if there is way to reference the cell of the TemplateColumn then how do you inject the missing control?
Do you use .innerHtml property of the reference? An example would be great.
Regards,
Arthur
0
Pavlina
Telerik team
answered on 28 Sep 2009, 04:15 PM
Hi Arthur,

Please refer to the following forum thread for more information about how to bind GridTemplateColumn
client side.
Additionally you can check the following links:
http://www.telerik.com/community/forums/aspnet-ajax/grid/gridtemplatecolumn-doesn-t-generate-inner-element-when-page-size-changed.aspx
http://www.telerik.com/community/forums/aspnet-ajax/grid/radgrid-client-side-binding-and-page-size-change.aspx

I hope this helps.

All the best,
Pavlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
Arthur Rogers
Top achievements
Rank 1
Answers by
Arthur Rogers
Top achievements
Rank 1
BaiH
Top achievements
Rank 1
Pavlina
Telerik team
Share this question
or