Hello,
I am trying to bind a WCF service to my grid (client side). I believe I have checked all the boxes to make this happen but what I see in a grid with empty rows (which match the # of rows returned).
I added a break point at the radgrid_databinding event and at that point the grid says "11 items in 2 pages" but once I click OK on the alert message the grid says No Items to be Displayed.
What am I missing here? Your response will be greatly appreciated. I have gone through every example and followed it as well as I could.
The JSON response in my Firebug returns the following
Here are my code snippets:
ASPX
This is the WCF code :
I am trying to bind a WCF service to my grid (client side). I believe I have checked all the boxes to make this happen but what I see in a grid with empty rows (which match the # of rows returned).
I added a break point at the radgrid_databinding event and at that point the grid says "11 items in 2 pages" but once I click OK on the alert message the grid says No Items to be Displayed.
What am I missing here? Your response will be greatly appreciated. I have gone through every example and followed it as well as I could.
The JSON response in my Firebug returns the following
Here are my code snippets:
ASPX
<telerik:RadGrid ID="PublisherGrid" runat="server" AllowSorting="true" AllowPaging="true" AllowMultiRowSelection="true" AutoGenerateColumns="false"> <MasterTableView ShowFooter="false" ItemStyle-Height="30px" AlternatingItemStyle-Height="30px"> <Columns> <telerik:GridClientSelectColumn UniqueName="Select" ItemStyle-Width="30px" HeaderStyle-Width="30px"></telerik:GridClientSelectColumn> <telerik:GridBoundColumn HeaderText="Id" ItemStyle-Width="30px" HeaderStyle-Width="30px" DataField="Id" HeaderStyle-Wrap="false" ItemStyle-Wrap="false"/> <telerik:GridBoundColumn HeaderText="Name" DataField="Name" HeaderStyle-Wrap="false" ItemStyle-Wrap="false"/> <telerik:GridBoundColumn HeaderText="FileNamePrefix" ItemStyle-Width="120px" HeaderStyle-Width="120px" DataField="FileNamePrefix" HeaderStyle-Wrap="false" ItemStyle-Wrap="false" /> <telerik:GridBoundColumn HeaderText="Delimeter" ItemStyle-Width="70px" HeaderStyle-Width="70px" DataField="Delimeter" HeaderStyle-Wrap="false" ItemStyle-Wrap="false" ItemStyle-HorizontalAlign="Center"/> <telerik:GridBoundColumn HeaderText="OutputLocation" DataField="OutputLocation" HeaderStyle-Wrap="false" ItemStyle-Wrap="false" /> <telerik:GridBoundColumn HeaderText="TimeStamp" ItemStyle-Width="120px" HeaderStyle-Width="120px" DataField="TimeStamp" HeaderStyle-Wrap="false" ItemStyle-Wrap="false" /> <telerik:GridBoundColumn HeaderText="Status" ItemStyle-Width="70px" HeaderStyle-Width="70px" DataField="Status" HeaderStyle-Wrap="false" ItemStyle-Wrap="false" ItemStyle-HorizontalAlign="Center"/> </Columns> <PagerStyle Mode="NextPrevAndNumeric" Position="Bottom" AlwaysVisible="true"></PagerStyle> </MasterTableView> <ClientSettings EnableRowHoverStyle="true"> <Selecting AllowRowSelect="true"/> <Resizing AllowColumnResize="true"/> <DataBinding SelectMethod="GetPublisherQueue" Location="http://localhost/Oyster.WCF/publisher.svc"> </DataBinding> <ClientEvents OnDataBinding="RadGrid1_DataBinding" OnDataBindingFailed="function () {alert('binding failed');}" /> </ClientSettings> <SelectedItemStyle CssClass="SelectedItem" /> </telerik:RadGrid>This is the WCF code :
[ServiceContract] public interface IPublisher { [OperationContract(Name = "GetPublisherQueue")] [WebInvoke(Method="POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)] PublisherQueueData GetPublisherQueue(int startRowIndex, int maximumRows); } [DataContract] public class PublisherQueue { [DataMember] public int Id { get; set; } [DataMember] public String Name { get; set; } [DataMember] public String FileNamePrefix { get; set; } [DataMember] public String Delimeter { get; set; } [DataMember] public String OutputLocation { get; set; } [DataMember] public String TimeStamp { get; set; } [DataMember] public String Status { get; set; } } public class PublisherQueueData { public int Count { get; set; } public List<PublisherQueue> Data { get; set; } }/////[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] [KnownType(typeof(PublisherQueue))] public class Publisher : IPublisher { List<PublisherQueue> publisherQueueList = new List<PublisherQueue>(); PublisherQueueData publisherQueueData = new PublisherQueueData(); public PublisherQueueData GetPublisherQueue(int startRowIndex, int maximumRows) { PopulatePublisherQueue(); publisherQueueData.Data = publisherQueueList; publisherQueueData.Count = publisherQueueList.Count; return publisherQueueData; } private void PopulatePublisherQueue() { Morningstar.Indexes.ETL.PublisherDataAccess publisherDataAccess = new PublisherDataAccess(); using (DataTable publisherQueueDataTable = publisherDataAccess.GetPublisherData()) { for(int i = 0; i < publisherQueueDataTable.Rows.Count - 1; i++) { PublisherQueue publisherQueueRecord = new PublisherQueue(); publisherQueueRecord.Id = Convert.ToInt32(publisherQueueDataTable.Rows[i]["PUBLISHER_ID"]); publisherQueueRecord.Name = publisherQueueDataTable.Rows[i]["PUBLISHER_NAME"].ToString(); publisherQueueRecord.FileNamePrefix = publisherQueueDataTable.Rows[i]["FILE_NAME"].ToString(); publisherQueueRecord.OutputLocation = publisherQueueDataTable.Rows[i]["OUTPUT_LOCATION"].ToString(); publisherQueueRecord.Delimeter = publisherQueueDataTable.Rows[i]["DELIMETER"].ToString(); publisherQueueRecord.TimeStamp = publisherQueueDataTable.Rows[i]["PUBLISH_TIMESTAMP"].ToString(); publisherQueueRecord.Status = publisherQueueDataTable.Rows[i]["STATUS"].ToString(); publisherQueueList.Add(publisherQueueRecord); } } } }