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

why radgrid is not binding json serialized string and showing empty fields ? please see snapshot inside.

1 Answer 151 Views
Grid
This is a migrated thread and some comments may be shown as answers.
khaled jendi
Top achievements
Rank 1
khaled jendi asked on 03 Oct 2012, 04:29 PM
hi,
I have jquery ajax code returning a json serialized string like this one:

{"":[{"serviceId":"Recording","errorDesc":"Function: BeginMonitoring();Microphone has been disconnected or is not available while trying to start record in Computer: khaled-pc","DATE_in":"02/Oct/2012","Time_in":"08:17"},{"serviceId":"Recording","errorDesc":"Function: BeginMonitoring();Microphone has been disconnected or is not available while trying to start record in Computer: khaled-pc","DATE_in":"02/Oct/2012","Time_in":"08:18"},{"serviceId":"Recording","errorDesc":"waveIn_RecordingStopped;USB microphone has been unpluged by force while microphone is recording.","DATE_in":"02/Oct/2012","Time_in":"08:20"},{"serviceId":"Recording","errorDesc":"Function: BeginMonitoring();Microphone has been disconnected or is not available while trying to start record in Computer: khaled-pc","DATE_in":"02/Oct/2012","Time_in":"08:21"},{"serviceId":"Recording","errorDesc":"Function: BeginMonitoring();Microphone has been disconnected or is not available while trying to start record in Computer: khaled-pc","DATE_in":"02/Oct/2012","Time_in":"08:21"},{"serviceId":"Recording","errorDesc":"waveIn_RecordingStopped;USB microphone has been unpluged by force while microphone is recording.","DATE_in":"02/Oct/2012","Time_in":"08:30"},{"serviceId":"Recording","errorDesc":"Function: BeginMonitoring();Microphone has been disconnected or is not available while trying to start record in Computer: khaled-pc","DATE_in":"02/Oct/2012","Time_in":"08:35"},{"serviceId":"Recording","errorDesc":"Function: BeginMonitoring();Microphone has been disconnected or is not available while trying to start record in Computer: khaled-pc","DATE_in":"02/Oct/2012","Time_in":"08:46"},{"serviceId":"Recording","errorDesc":"waveIn_RecordingStopped;USB microphone has been unpluged by force while microphone is recording.","DATE_in":"02/Oct/2012","Time_in":"09:30"},{"serviceId":"Transferring","errorDesc":"IsFileLocked Function;The file recorded in: 02/Oct/2012 at: 12:27 has been deleted or renamed from machine: khaled-pc","DATE_in":"02/Oct/2012","Time_in":"13:44"},{"serviceId":"Transferring","errorDesc":"IsFileLocked Function;The file recorded in: 02/Oct/2012 at: 13:27 has been deleted or renamed from machine: khaled-pc","DATE_in":"02/Oct/2012","Time_in":"14:44"},{"serviceId":"Transferring","errorDesc":"IsFileLocked Function;The file recorded in: 02/Oct/2012 at: 13:27 has been deleted or renamed from machine: khaled-pc","DATE_in":"02/Oct/2012","Time_in":"14:46"},{"serviceId":"Recording","errorDesc":"waveIn_RecordingStopped;USB microphone has been unpluged by force while microphone is recording.","DATE_in":"02/Oct/2012","Time_in":"16:34"},{"serviceId":"Recording","errorDesc":"waveIn_RecordingStopped;USB microphone has been unpluged by force while microphone is recording.","DATE_in":"03/Oct/2012","Time_in":"09:04"},{"serviceId":"Recording","errorDesc":"waveIn_RecordingStopped;USB microphone has been unpluged by force while microphone is recording.","DATE_in":"03/Oct/2012","Time_in":"14:15"},{"serviceId":"Recording","errorDesc":"waveIn_RecordingStopped;USB microphone has been unpluged by force while microphone is recording.","DATE_in":"03/Oct/2012","Time_in":"14:33"},{"serviceId":"Recording","errorDesc":"waveIn_RecordingStopped;USB microphone has been unpluged by force while microphone is recording.","DATE_in":"03/Oct/2012","Time_in":"14:40"},{"serviceId":"Recording","errorDesc":"waveIn_RecordingStopped;USB microphone has been unpluged by force while microphone is recording.","DATE_in":"03/Oct/2012","Time_in":"17:06"},{"serviceId":"Transferring","errorDesc":"The recorded file on: 02/Oct2012 at: 13:/O has been deleted by force, the deleted file is:LARC_1_20121002_1441.mp3","DATE_in":"03/Oct/2012","Time_in":"09:29"}]}

and I want to fill it in rad grid data source, so I am doing this:
((note my javascript code is in another .js file and I am embedding it in my aspx page))
var rdScreenings = $telerik.$("[id$='rdScreenings']").attr("id");
var rdScreenings111 = $find(rdScreenings);
var tableView1 = rdScreenings111.get_masterTableView();
tableView1.set_dataSource(res);//res is the serialized string...
tableView1.dataBind();

and this is the rad grid:
<telerik:RadGrid ID="rdScreenings" runat="server" AllowPaging="True" AllowSorting="True"
    AutoGenerateColumns="False" CssClass="ScreeningListControl" GridLines="None">
    <PagerStyle NextPageText="View more locations" />
    <MasterTableView>
        <RowIndicatorColumn>
            <HeaderStyle Width="20px" />
        </RowIndicatorColumn>
        <ExpandCollapseColumn>
            <HeaderStyle Width="20px" />
        </ExpandCollapseColumn>
        <Columns>
                                        <telerik:GridBoundColumn DataField="serviceId" HeaderText="Service Name" />
                                        <telerik:GridBoundColumn DataField="errorDesc" HeaderText="Error Description" />
                                        <telerik:GridBoundColumn DataField="DATE_in" HeaderText="Checking Date" />
                                        <telerik:GridBoundColumn DataField="Time_in" HeaderText="Checking Time" />
    </Columns>
    </MasterTableView>
    <ClientSettings>
        <ClientEvents OnCommand="RadGrid_OnCommand" />
    </ClientSettings>
</telerik:RadGrid>

when I click a button to load my rad grid, it takes some time (this time is calculated after returning the string from my server and I got sometimes error message from firefox says this script takes long time and it ask me if I want to stop it), and then I got all grid fields are empty, and paging is not working too !
please see the snapshot:

1 Answer, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 08 Oct 2012, 11:10 AM
Hi Khaled,

This is so because RadGrid can bind only to the actual objects inside the array you pass, not the array itself. In other words, you should either pass only the JSON inside the square brackets to the master table:
[{ "serviceId": "Recording", "errorDesc": "Function: BeginMonitoring();Microphone has been disconnected or is not available while trying to start record in Computer: khaled-pc", "DATE_in": "02/Oct/2012", "Time_in": "08:17" }, .......];

or give a name to the array:
{ "Table": [{ "serviceId": "Recording", "errorDesc": "Function: BeginMonitoring();Microphone has been disconnected or is not available while trying to start record in Computer: khaled-pc", "DATE_in": "02/Oct/2012", "Time_in": "08:17" }, ........] };

tableView1.set_dataSource(res.Table);


All the best,
Tsvetina
the Telerik team
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 their blog feed now.
Tags
Grid
Asked by
khaled jendi
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
Share this question
or