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

GridTemplateColumn empty when RadGrid bound with JSON data on client side

3 Answers 74 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rob
Top achievements
Rank 1
Rob asked on 20 Dec 2013, 06:56 PM
Hi,
I am trying to bind RadGrid with JSON Data on Client side. GridBoundColumns display data ok, but GridTemplateColumn is empty.
My code is below. Please, help.

<
telerik:GridTemplateColumn UniqueName="Description" DataField=Description" AllowFiltering="false" >
     <ItemTemplate>
         <asp:Label ID="Description" runat="server"  />
     </ItemTemplate>
</telerik:GridTemplateColumn>
 
 $.ajax({
 
                type: 'POST',
 
                contentType: 'application/json; charset=utf-8',
 
                data: '{}',
 
                dataType: 'JSON',
                url: '../../Services/Service.svc/GetList',
                success: function (result) {
                 var GridData = result.GetListResult;
                 if (GridData.length > 0) {
                     var masterTable = $find("<%=gvList.ClientID %>").get_masterTableView();
                     masterTable.set_dataSource(GridData);
                     masterTable.dataBind();
}

3 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 21 Dec 2013, 05:19 AM
Hello,

You have to create DOM manually for Template control.

<telerik:GridTemplateColumn UniqueName="Description" DataField=Description" AllowFiltering="false" >
     <ItemTemplate>
         <asp:Label ID="Description" runat="server"  />
     </ItemTemplate>
</telerik:GridTemplateColumn>

<script>
            function RowDataBound(sender, args) {
                var celName = args.get_item().get_cell("Description");
                var input = document.createElement("span");
                      input.innerHTML = args.get_dataItem().Description;
    
                celName.appendChild(input);
            }
        </script>

Let me know if any concern.

Thanks,
Jayesh Goyani
0
Rob
Top achievements
Rank 1
answered on 23 Dec 2013, 12:04 PM
Hi, Jayesh,

Thank you for the response. The code that you provided doesn't work for me. I am getting error: celName is null.

Please help.
0
Eyup
Telerik team
answered on 25 Dec 2013, 08:32 AM
Hi Rob,

Please try to use ClientItemTemplate provided by RadGrid and let me know about the result:
http://demos.telerik.com/aspnet-ajax/grid/examples/data-binding/client-side/client-item-template/defaultcs.aspx

Looking forward to your reply.

Regards,
Eyup
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Grid
Asked by
Rob
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Rob
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or