datecolumn don't work with remote data

  1. #1

    datecolumn don't work with remote data

    When I try load data from server using http proxy, gridpanel don't display it.
    I create sample to reproduce it

    Full sample
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="RemoteDataBug.aspx.cs" Inherits="Intranet_v4_Web.Problems.RemoteDataBug" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" 
    %><!DOCTYPE html>
    <html>
    <head runat="server">
        <title>Seznam etap</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <ext:ResourcePlaceHolder runat="server" Mode="ScriptFiles" />
    	<ext:ResourcePlaceHolder runat="server" Mode="Style" />    
    </head>
    <body>
        <form runat="server" enableviewstate="false">
        <ext:ResourceManager runat="server" locale="cs-CZ" />
        <ext:Window 
            runat="server" 
            Title="Seznam etap" 
            Icon="Application"
            maximized="true"
            maximizable="false"
            closable="false"
            plain="true"
            border="false"
            BodyBorder="false"
            Resizable="false"
            modal="true"
            >
            <items>
        <ext:BorderLayout runat="server">
            <center>
    	        <ext:GridPanel id="GridPanelSeznam" 
    		        runat="server" 
    		        autowidth="true"
                    layout="Fit"
    		        >
                <store>
                    <ext:store runat="server">	
                        <Proxy>
                            <ext:HttpProxy Method="Get" Url="RemoteDataBug.aspx/AllData" 
                                           json="true" DisableCaching="true" />
                        </Proxy>
    	                <Reader>
    		                <ext:JsonReader root="d.Data" totalproperty="d.TotalRecords">
                                <Fields>
                                    <ext:RecordField Name="Id" type="Int" />
                                    <ext:RecordField Name="Date" type="Date" />
                                    <ext:RecordField Name="NullableDate" type="Date" />                                
                                </Fields>
                            </ext:JsonReader>
    	                </Reader> 
                        <AutoLoadParams>
                            <ext:Parameter Name="start" Value="0" Mode="Raw" />
                            <ext:Parameter Name="limit" Value="10" Mode="Raw" />
                        </AutoLoadParams>                    
                    </ext:store>                       
                </store>
                <columnmodel runat="server">
                    <columns>     
                        <ext:numbercolumn Header="Id" DataIndex="Id" Width="100" Sortable="true" />
                        <ext:datecolumn Header="Date" DataIndex="Date" Width="200" />
                        <ext:datecolumn Header="NullableDate" DataIndex="NullableDate" Width="200" />                    
                    </columns>                 
                </columnmodel>
                <SelectionModel>
    				<ext:RowSelectionModel runat="server" singleselect="true" />
    			</SelectionModel>	
                <View>
    				<ext:GridView runat="server" ForceFit="true" />
    			</View>
                <LoadMask ShowMask="true" />
                <BottomBar>                
                    <ext:PagingToolbar runat="server" DisplayInfo="true" pagesize="10" />
                </BottomBar>   
                </ext:GridPanel>
            </center>               
        </ext:BorderLayout> 
        </items> 
        </ext:Window>
        </form>
    </body>
    </html>
    codebehind:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.Script.Services;
    using System.ComponentModel;
    using System.Web.Services;
    
    namespace Intranet_v4_Web.Problems
    {
        public class sampleData {
            public int Id { get; set; }
            public DateTime Date { get; set; }
            public DateTime? NullableDate { get; set; }
        }
    
        public partial class RemoteDataBug : System.Web.UI.Page
        {
    
            [ScriptMethod(UseHttpGet = true)]
            [WebMethod(MessageName = "AllData", Description = "Retrive all data for grid")]
            public static Ext.Net.Paging<sampleData> AllDate()
            {
                return DataWithSort(0,10);
            }
    
            [ScriptMethod(UseHttpGet = true)]
            [WebMethod(MessageName = "Data", Description = "Retrive all data for grid")]
            public static Ext.Net.Paging<sampleData> DataWithSort(
                    [DefaultValue(0)]int start = 0,
                    [DefaultValue(0)]int limit = 0
                )
            {
                List<sampleData> items = new List<sampleData>();
                for (int i = 0; i < 100; i++)
    			{
    			    items.Add(new sampleData{
                        Id = i, 
                        Date = DateTime.Now, 
                        NullableDate = (i % 2 != 0) ? DateTime.Now : (DateTime?)null});
    			}
                
                var range = (start < 0 || limit <= 0) ? items : items.Skip(start).Take(limit);
    
                return new Ext.Net.Paging<sampleData>(range, items.Count());
            }
        }
    }
  2. #2
    Hi,

    It is not bug.
    You have to specify correct DateFormat for RecordField
  3. #3

    Correct example

    Hi Vladimir,
    thank you for your reply, but i try modify fields definition like this:
                                    <ext:RecordField Name="Id" type="Int" />
                                    <ext:RecordField Name="Date" type="Date" dateformat="dd.MM.yyyy hh:ss" />
                                    <ext:RecordField Name="NullableDate" type="Date" dateformat="yyyy" />
    And it still don't work.

    Can you please provide me corrected sample?

    BTW: I also can't find how to make this sample pagable. When I try use DataWithSort instead All data, I got exception about missing parameter.

    Thank you Petr
  4. #4
    How date is look in the response?
  5. #5

    response

    Quote Originally Posted by Vladimir View Post
    How date is look in the response?
    response (from firebug)
    {"d":{"Data":[{"__type":"Intranet_v4_Web.Problems.sampleData","Id":0,"Date":"\/Date(1307528001582)\/","NullableDate":null},{"__type":"Intranet_v4_Web.Problems.sampleData","Id":1,"Date":"\/Date(1307528001582)\/","NullableDate":"\/Date(1307528001582)\/"},{"__type":"Intranet_v4_Web.Problems.sampleData","Id":2,"Date":"\/Date(1307528001582)\/","NullableDate":null},{"__type":"Intranet_v4_Web.Problems.sampleData","Id":3,"Date":"\/Date(1307528001582)\/","NullableDate":"\/Date(1307528001582)\/"},{"__type":"Intranet_v4_Web.Problems.sampleData","Id":4,"Date":"\/Date(1307528001582)\/","NullableDate":null},{"__type":"Intranet_v4_Web.Problems.sampleData","Id":5,"Date":"\/Date(1307528001582)\/","NullableDate":"\/Date(1307528001582)\/"},{"__type":"Intranet_v4_Web.Problems.sampleData","Id":6,"Date":"\/Date(1307528001582)\/","NullableDate":null},{"__type":"Intranet_v4_Web.Problems.sampleData","Id":7,"Date":"\/Date(1307528001582)\/","NullableDate":"\/Date(1307528001582)\/"},{"__type":"Intranet_v4_Web.Problems.sampleData","Id":8,"Date":"\/Date(1307528001582)\/","NullableDate":null},{"__type":"Intranet_v4_Web.Problems.sampleData","Id":9,"Date":"\/Date(1307528001582)\/","NullableDate":"\/Date(1307528001582)\/"}],"TotalRecords":100}}
  6. #6
    Hi,

    Please use DateFormat="M$"
  7. #7

    Thank you

    Thank you, it worked now.
    Can you explain it a little to me? First I think it's a microsoft joke :-)

    Also I want to ask you for help how to update my sample to work with paging.
    I try some combinations with autoloadparams, baseparams, but without luck.

Similar Threads

  1. [CLOSED] CalendarPanel Remote Data
    By T3rryChan in forum 2.x Legacy Premium Help
    Replies: 9
    Last Post: May 14, 2012, 5:03 PM
  2. [CLOSED] Calendar - return more event values from remote data
    By craig2005 in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Feb 08, 2012, 4:39 AM
  3. [CLOSED] Local Paging for Remote Data Issue
    By dnguyen in forum 1.x Legacy Premium Help
    Replies: 26
    Last Post: Apr 12, 2011, 12:50 AM
  4. [CLOSED] Renderer does not work on DateColumn in GridPanel
    By Jurke in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Feb 04, 2011, 11:04 AM
  5. [CLOSED] [1.0] Gridview local data paging with remote data
    By BerndDA in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Jul 15, 2010, 10:29 AM

Posting Permissions