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

[Solved] GridTemplateColumn doesn't generate inner element when page size changed

1 Answer 140 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Xing
Top achievements
Rank 1
Xing asked on 29 Mar 2009, 07:03 PM

I have a client-bind Grid which has GridTemplateColumn to show a checkbox.

 

<

 

telerik:RadGrid ID="RadGrid1" EnableViewState="False" Skin="WebBlue" runat="server"

 

 

 

    AllowPaging="True" AllowSorting="True" AllowFilteringByColumn="True"

 

 

 

    AutoGenerateColumns="False" Width="100%"

 

 

    EnableAJAXLoadingTemplate="True" EnableAJAX="True" GridLines="None" >

 

 

 

    <MasterTableView AllowNaturalSort="false" AccessKey="x"

 

 

        AllowFilteringByColumn="True"

 

 

        ClientDataKeyNames="IsReviewed, ID, Message, Category" CellSpacing="-1" >

 

 

 

        <Columns>

 

 

 

            <telerik:GridTemplateColumn HeaderText="Review" >

 

 

                <ItemTemplate>

 

 

                    <asp:CheckBox ID="CheckBox" runat="server" />

 

 

 

                </ItemTemplate>

 

 

            </telerik:GridTemplateColumn>

 

 

            <telerik:GridDateTimeColumn DataField="TimeStamp" HeaderText="Date and Time" DataFormatString="{0:M/d/yyyy h:mm tt}" UniqueName="Time"/>

 

 

        </Columns>

 

 

 

    </MasterTableView>
    <ClientSettings AllowKeyboardNavigation="True">

 

 

         <ClientEvents OnRowDataBound="RowDataBound" ></ClientEvents>

 

 

         <DataBinding SelectMethod="GetDataAndCount" Location="~/service/Service.svc" SortParameterType="Linq" FilterParameterType="Linq" >

 

 

 

         </DataBinding>

 

 

 

    </ClientSettings>

Here is the script to handle data bind on check box:

 

 

function RowDataBound(sender, args) {

 

 

    var radTextBox1 = args.get_item().findElement("CheckBox");

 

 

    radTextBox1.checked = args.get_dataItem()["IsReviewed"];

 

}

In normal situation, everything is fine. However, when I change the page size, the client side didn't create the check box for the increased new rows. The script is failed due to can't find the radTextBox1. I did some trace, the data is succeeded binding, other columns are fine, only this GridTemplateColumn has issue to create.

How can I reslove this issue?

1 Answer, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 01 Apr 2009, 03:11 PM
Hello Xing,

RadGrid bound client-side will not create any control hosted inside GridTemplateColumn for the rows which are more then PageSize.
You should listen for RowDataBound client side event and add desired controls to the corresponding cell of the item(which is available in the handler arguments).

You can also use RadGrid client-side API to achieve this:
Getting RadGrid client object and related topics.

Regards,
Nikolay
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Xing
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Share this question
or