[CLOSED] WebService return date but nothing in grid

  1. #1

    [CLOSED] WebService return date but nothing in grid



    I have such code:

    *   <ext:Store ID="StoreDocuments" runat="server" OnRefreshData="StoreDocuments_Refresh">
    *       <Proxy>
    *           <ext:HttpProxy Method="POST" Url="Services/CrossData.asmx/GetDocuments" Json="true">
    *           </ext:HttpProxy>
    *       </Proxy>
    *       <Reader>
    *           <ext:JsonReader Root="d" ReaderID="DocuementName">
    *               <Fields>
    *                   <ext:RecordField Name="DocuementName" />
    *                   <ext:RecordField Name="Language" />
    *                   <ext:RecordField Name="DocumentProgress" />
    *                   <ext:RecordField Name="DocumentStatus" />
    *                   <ext:RecordField Name="Deadline" Type="Date" />
    *                   <ext:RecordField Name="DocumentDescription" />
    *               </Fields>
    *           </ext:JsonReader>
    *       </Reader>
    *       <BaseParams>
    *           <ext:Parameter Name="ProjectID" Value="#{ProjectsGridPanel}.getSelectionModel().hasSelection() ? #{ProjectsGridPanel}.getSelectionModel().getSelected().id : -1"
    *               Mode="Raw" />
    *       </BaseParams>
    *       <Listeners>
    *           <LoadException Handler="Ext.Msg.alert('Products - Load failed', e.message || response.statusText);" />
    *       </Listeners>
    *   </ext:Store>
    *

    and grid panel code:

    
    *                   <ext:Panel ID="PanelDocuments" runat="server" Height="100px" Title="Documents" IDMode="Legacy">
    *                       <Listeners>
    *                           <Expand Handler="#{StoreDocuments}.reload();" />
    *                       </Listeners>
    *                       <Body>
    *                           <ext:FitLayout ID="FitLayout2" runat="server">
    *                               <ext:GridPanel ID="DocumentsGridPanel" runat="server" StoreID="StoreDocuments" AutoExpandColumn="DocuementName"
    *                                   Border="false">
    *                                   <ColumnModel ID="ColumnModel1" runat="server">
    *                                       <Columns>
    *                                           <ext:Column ColumnID="DocuementName" DataIndex="DocuementName" Header="Docuement Name" />
    *                                           <ext:Column DataIndex="Language" Header="Language" />
    *                                           <ext:Column DataIndex="DocumentProgress" Header="Progress" />
    *                                           <ext:Column DataIndex="DocumentStatus" Header="Status" />
    *                                           <ext:Column DataIndex="Deadline" Header="Deadline"  />
    *                                           <ext:Column DataIndex="DocumentDescription" Header="Description" />
    *                                       </Columns>
    *                                   </ColumnModel>
    *                                   <LoadMask ShowMask="true" />
    *                                   <SelectionModel>
    *                                       <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" SingleSelect="true" />
    *                                   </SelectionModel>
    *                               </ext:GridPanel>
    *                           </ext:FitLayout>
    *                       </Body>
    *                   </ext:Panel>
    Deadline is in date format passed from web serivce like but nothing is shown in grid. if I set <ext:RecordField Name="Deadline" Type="Date" /> as <ext:RecordField Name="Deadline" /> it returns string that is passed by webservice
  2. #2

    RE: [CLOSED] WebService return date but nothing in grid

    Hi,

    What format of date which returns by web-service? I think you need to set DateFormat for RecordField
  3. #3

    RE: [CLOSED] WebService return date but nothing in grid



    The data from web service in json looks like:

    
    {"d":
    [{"__type":"Document","DocuementName":"FirstDocument","Language":"English","DocumentProgress":"100%","DocumentStatus":"Finished","Deadline":"\/Date(1230746400000)\/","DocumentDescription":"SecondDocument"},
    {"__type":"Document","DocuementName":"SecondDocument","Language":"Russian","DocumentProgress":"40%","DocumentStatus":"Started","Deadline":"\/Date(1233424800000)\/","DocumentDescription":"Addasnt"}]}
    *Web service is simple:

    
    /// <summary>
    /// Summary description for CrossData
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.*
    *[System.Web.Script.Services.ScriptService]
    public class CrossData : System.Web.Services.WebService {
    
    *   public CrossData () {
    
    *       //Uncomment the following line if using designed components*
    *       //InitializeComponent();*
    *   }
    
    *[WebMethod]
    *public Document[] GetDocuments(int ProjectID)
    *{
    *	List<Document> documents = new List<Document>();
    *	if (ProjectID == 1)
    *	{
    *		documents.Add(new Document() { Deadline = new DateTime(2009, 01, 01), DocuementName = "FirstDocument", DocumentDescription = "SecondDocument", DocumentProgress = "100%", DocumentStatus = "Finished", Language = "English" });
    *		documents.Add(new Document() { Deadline = new DateTime(2009, 02, 01), DocuementName = "SecondDocument", DocumentDescription = "Addasnt", DocumentProgress = "40%", DocumentStatus = "Started", Language = "Russian" });
    *		documents.Add(new Document() { Deadline = new DateTime(2009, 03, 01), DocuementName = "ThirdDocument", DocumentDescription = "Seasdffasocument", DocumentProgress = "90%", DocumentStatus = "Executed", Language = "English" });
    *	}
    *	if (ProjectID == 2)
    *	{
    *		documents.Add(new Document() { Deadline = new DateTime(2009, 01, 01), DocuementName = "FirstDocument", DocumentDescription = "SecondDocument", DocumentProgress = "100%", DocumentStatus = "Finished", Language = "English" });
    *		documents.Add(new Document() { Deadline = new DateTime(2009, 02, 01), DocuementName = "SecondDocument", DocumentDescription = "Addasnt", DocumentProgress = "40%", DocumentStatus = "Started", Language = "Russian" });
    *	}
    *	if (ProjectID == 3)
    *	{
    *		documents.Add(new Document() { Deadline = new DateTime(2009, 01, 01), DocuementName = "FirstDocument", DocumentDescription = "SecondDocument", DocumentProgress = "100%", DocumentStatus = "Finished", Language = "English" });
    *	}
    *	return documents.ToArray();
    *}
    }
    
    
    
    public class Document
    {
    *public Document()
    *{
    *}
    
    *public string DocuementName { get; set; }
    *public string Language { get; set; }
    *public string DocumentProgress { get; set; }
    *public string DocumentStatus { get; set; }
    *public DateTime Deadline { get; set; }
    *public string DocumentDescription { get; set; }
    
    }
  4. #4

    RE: [CLOSED] WebService return date but nothing in grid

    Hi,

    1. Add converter to your RecordField
    <ext:RecordField Name="Deadline" Type="Date">
                                <Convert Handler="return Ext.decode(value.replace(/\/(Date\([0-9-]+\))\//gi, 'new $1'));" />
                            </ext:RecordField>
    2. Add Renderer to Column
    <ext:Column DataIndex="Deadline" Header="Deadline">
                            <Renderer Fn="Ext.util.Format.dateRenderer('d M Y')" />
                        </ext:Column>

Similar Threads

  1. Replies: 4
    Last Post: Jul 25, 2012, 5:45 AM
  2. Replies: 5
    Last Post: Nov 29, 2011, 7:22 PM
  3. Grid x Webservice x ComboBox
    By LLdeOJ in forum 1.x Help
    Replies: 1
    Last Post: Dec 06, 2010, 9:15 PM
  4. How can I get return value webservice?
    By relativ in forum 1.x Help
    Replies: 0
    Last Post: Dec 02, 2009, 4:33 AM
  5. date format for all date fields in grid?
    By marcmvc in forum 1.x Help
    Replies: 0
    Last Post: Dec 01, 2009, 3:41 PM

Posting Permissions