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

WCF Client Side Grid Binding

1 Answer 17 Views
Grid
This is a migrated thread and some comments may be shown as answers.
BALA MUKUND
Top achievements
Rank 1
BALA MUKUND asked on 24 Sep 2012, 06:01 PM
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

  1. GetPublisherQueueResult{Count:11,…}
    1. Count11
    2. Data[{Delimeter:|, FileNamePrefix:GLB_CON_EOD_, Id:2, Name:EOD Constituent,…},…]
      1. 0{Delimeter:|, FileNamePrefix:GLB_CON_EOD_, Id:2, Name:EOD Constituent,…}
      2. 1{Delimeter:|, FileNamePrefix:GLB_IDX_EOD_, Id:3, Name:EOD Index,…}
      3. 2{Delimeter:|, FileNamePrefix:GLB_IDX_DIV_EOD_, Id:4, Name:EOD Divisor,…}
      4. 3{Delimeter:|, FileNamePrefix:GLB_IDX_DIV_SOD_, Id:5, Name:NSOD Divisor,…}
      5. 4{Delimeter:|, FileNamePrefix:GLB_CON_SOD_, Id:6, Name:SOD Constituent,…}
      6. 5{Delimeter:|, FileNamePrefix:GLB_IDX_CHG_, Id:7, Name:Change,…}
      7. 6{Delimeter:|, FileNamePrefix:GLB_CON_EOD_, Id:8, Name:EOD Constituent,…}
      8. 7{Delimeter:|, FileNamePrefix:GLB_IDX_EOD_, Id:9, Name:Index,…}
      9. 8{Delimeter:|, FileNamePrefix:GLB_IDX_DIV_EOD_, Id:10, Divisor,…}
      10. 9{Delimeter:|, FileNamePrefix:GLB_IDX_DIV_SOD_, Id:11, Divisor,…}
      11. 10{Delimeter:|, FileNamePrefix:GLB_CON_SOD_, Id:12, Name:Constituent,…}

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);
 
                }
 
            }
        }
    }

1 Answer, 1 is accepted

Sort by
0
BALA MUKUND
Top achievements
Rank 1
answered on 24 Sep 2012, 09:26 PM
Please ignore this question. I forgot to AJAX enable the WCF. I assumed it was enabled by default. Sorry for the confusion.
Tags
Grid
Asked by
BALA MUKUND
Top achievements
Rank 1
Answers by
BALA MUKUND
Top achievements
Rank 1
Share this question
or