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

Grid won't bind at client

1 Answer 93 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Thomas
Top achievements
Rank 1
Thomas asked on 07 Mar 2014, 08:31 PM
Trying to bind the grid client-side.  However, no data is displayed even though valid JSON is being passed into assignDataSOurce.  Looks like it's dying on line 3 of the JS block (masterTable.set_dataSource(ds.d);). 


1.<telerik:RadGrid ID="RadGrid1" runat="server" Skin="Metro"
2.                    AutoGenerateColumns="False" ViewStateMode="Disabled" ShowHeader="False">
3.                    <ClientSettings>
4.                        <Selecting AllowRowSelect="True" />
5.                        <Resizing AllowRowResize="False" ShowRowIndicatorColumn="False" AllowColumnResize="True" />
6.                        <Scrolling AllowScroll="False" />
7.                        <ClientEvents OnRowSelected="RowSelectionChanged"></ClientEvents>
8.                    </ClientSettings>
01.function assignDataSource(ds) {
02.            var masterTable = $("<%= RadGrid1.ClientID %>").get_masterTableView();
03.            masterTable.set_dataSource(ds.d);
04.            masterTable.dataBind();
05.        }
06.         
07.        function GetData() {
08.            
09. 
10.                var searchObj;
11.                var searchMethod;
12. 
13.                              $.ajax({
14.                    type: "POST",
15.                    contentType: "application/json; charset=utf-8",
16.                    url: "/WebServices/RwsSearch.svc/" + searchMethod,
17.                    data: JSON.stringify(searchObj),
18.                    dataType: "json",
19.                    success: function (data, textStatus) {
20.                        try {
21.                            assignDataSource(data);
22. 
23.                        } catch (err) {
24.                            //ConfirmOpen("Sorry, unable to search. " + err + " : " + textStatus);
25.                        }
26.                    },
27.                    failure: function (errMsg, textStatus) {
28.                        //ConfirmOpen(errMsg + " : " + textStatus);
29.                    }
30.                });
31.             
32.        }




1 Answer, 1 is accepted

Sort by
0
Radoslav
Telerik team
answered on 12 Mar 2014, 11:42 AM
Hello Thomas,

Could you please try passing the ds parameter as a data source of the masterTable instead of ds.d:
function assignDataSource(ds) {
            var masterTable = $("<%= RadGrid1.ClientID %>").get_masterTableView();
            masterTable.set_dataSource(ds);
            masterTable.dataBind();
        }
Also could you please make sure that you pass the tableView’s virtualItemCount to the number of returned items as is shown in the following example:
http://demos.telerik.com/aspnet-ajax/grid/examples/data-binding/client-side/programmatic/defaultcs.aspx

Looking forward for your reply.

Regards,
Radoslav
Telerik
 

DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.

 
Tags
Grid
Asked by
Thomas
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
Share this question
or