PDA

View Full Version : [CLOSED] Datefield / German error



tMp
Mar 13, 2014, 10:57 AM
Hi

Please have a look at this demo. Pre-requisit: The language has to be a german one, where March is like M?rz. The error only occurs when I select M?rz, every other Month without the ? has no problem at all. Is this a framework error?


<%@ Page Language="C#" %>


<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<script runat="server">

protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{

}
}

[DirectMethod]
public void submitDate()
{
System.Data.SqlTypes.SqlDateTime dt = X.GetCmp<DateField>("dfTest", new DateField.Config() { Format = "MMM yyyy" }).SelectedDate;
X.Msg.Alert("Date submited", dt.ToString()).Show();
}

</script>

<!DOCTYPE html>

<html>
<head id="Head" runat="server">
<title></title>

</head>
<body>
<form id="Form" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" Locale="de-CH" />

<ext:DateField runat="server" ID="dfTest" AllowBlank="false" FieldLabel="Date" EmptyText = "required" Format = "MMM yyyy" Type="Month"></ext:DateField>
<ext:Button runat="server" Text="Submit" OnClientClick="App.direct.submitDate()"></ext:Button>

</form>
</body>
</html>

thank you and best regards

Daniil
Mar 13, 2014, 12:00 PM
Hi @tMp,

I see the following. Please clarify what Ext.NET version are you using?

8131

tMp
Mar 13, 2014, 1:10 PM
That is correct what you see. Please select M?r and push the submit button. I always get an exception that the date must be between minValue and maxValue. But only when I select M?r, any other month works fine.

I am still on 2.4 (because 2.5 breaks with a infinite scrolling list I have and I first have to fix some other errors because the app is already in use)

Daniil
Mar 13, 2014, 3:42 PM
Got it. There is inconsistency between .NET and ExtJS localizations.

This returns "Mrz 2014".

X.Msg.Alert("", DateTime.Now.ToString("MMM yyyy", new System.Globalization.CultureInfo("de"))).Show();

It is why a March date cannot be deserialized.

Please try this fix:

Ext.onReady(function() {
Ext.Date.getShortMonthName = function(month) {
if (Ext.Date.monthNames[month] === "M?rz") {
return "Mrz";
}

return Ext.Date.monthNames[month].substring(0, 3);
};
});

tMp
Mar 13, 2014, 4:33 PM
In the demo it is working if I change the '?' to a '?' in M?rz but I am creating this window with a form by directmethod after a user button click and then it is not changing the short month name... I assume onReady doesn't work with the directmethod?

Daniil
Mar 13, 2014, 4:57 PM
Hmm, not sure what you exactly do. Please provide a test case.

tMp
Mar 13, 2014, 5:38 PM
I can't reproduce it at the moment. If I do a demo everything works. The only difference I have is that in my app I have a masterfile and the onReady-Statement gets completely ignored. I pasted it where I have all my other javascript function and I even replaced the


Ext.Date.getShortMonthName = function(month) {
if (Ext.Date.monthNames[month] === "M?rz") {
return "Mrz";
}

return Ext.Date.monthNames[month].substring(0, 3);
};

Part with a simple alert('test'); and even that doesn't get called... All the other functions are working flawlessly. Is there a specific place where it should be?

Daniil
Mar 14, 2014, 4:39 AM
Please post the Master Page. Maybe, I will be able to understand what is wrong.

Daniil
Mar 14, 2014, 4:56 AM
Meanwhile, I've committed the fix to the SVN trunk in the revision #5719. It will go to v2.5.1.

tMp
Mar 14, 2014, 8:49 AM
Thank you very much!

I got a master sample now where it ignores the onready:

KDM7.master

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="KDM7.master.cs" Inherits="KDM7" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">

<ext:ResourceManager ID="ResourceManager" runat="server" Locale="de-CH"></ext:ResourceManager>

<title></title>

<asp:ContentPlaceHolder id="CPH_HEAD" runat="server"></asp:ContentPlaceHolder>

</head>
<body>
<form id="form" runat="server">

<asp:ContentPlaceHolder ID="CPH_BODY" runat="server">

</asp:ContentPlaceHolder>

</form>
</body>
</html>

KDM7.master.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class KDM7 : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{

}
}


test.aspx

<%@ Page Title="" Language="C#" MasterPageFile="~/KDM7.master" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<script runat="server">

protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{

}
}

[DirectMethod]
public void createWindow()
{
// create sample data
System.Data.DataTable dt = new System.Data.DataTable();

System.Data.DataColumn dc = new System.Data.DataColumn("ID");
dc.DataType = System.Type.GetType("System.String");
dt.Columns.Add(dc);
dc = new System.Data.DataColumn("VALUE");
dc.DataType = System.Type.GetType("System.Int32");
dt.Columns.Add(dc);
System.Data.DataRow dr = dt.NewRow();
dr[0] = "1";
dr[1] = 100;
dt.Rows.Add(dr); dr = dt.NewRow();
dr[0] = "2";
dr[1] = 75;
dt.Rows.Add(dr); dr = dt.NewRow();
dr[0] = "3";
dr[1] = 55;
dt.Rows.Add(dr);

Window win = new Window
{
Title = "Date Test 1",
ManageHeight = true,
Items = {
new GridPanel {
AutoScroll = true,
MaxHeight = 500,
Store = {
new Ext.Net.Store {
Model = {
new Ext.Net.Model {
Fields = {
new Ext.Net.ModelField { Name = "ID", Type = Ext.Net.ModelFieldType.String },
new Ext.Net.ModelField { Name = "VALUE", Type = Ext.Net.ModelFieldType.Int }
}
}
},
DataSource = dt
}
},
ColumnModel = {
Columns = {
new Ext.Net.CommandColumn {
Width = 30,
Commands = { new GridCommand { Icon = Icon.BookEdit, CommandName = "edit" } },
Listeners = { Command = { Handler = "App.direct.createWindow2()" }}
},
new Ext.Net.Column { Text = "Value", DataIndex = "VALUE", Width = 100 }
}
}
}
}
};
win.Render();
}

[DirectMethod]
public void createWindow2()
{
Window win = new Window
{
Title = "Date Test 2",
Width = 300,
Items = {
new DateField { FieldLabel = "Date", Format = "MMM yyyy", Type = DatePickerType.Month }
}
};
win.Render();
}

</script>

<asp:Content ID="Content1" ContentPlaceHolderID="CPH_HEAD" Runat="Server">

<script>

Ext.onReady(function () {
Ext.Date.getShortMonthName = function (month) {
if (Ext.Date.monthNames[month] === "M?rz") {
return "Mrz";
}

return Ext.Date.monthNames[month].substring(0, 3);
};
});

</script>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="CPH_BODY" Runat="Server">

<ext:Button ID="Button1" runat="server" Text="Create Window 1" OnClientClick="App.direct.createWindow()"></ext:Button>

</asp:Content>

Daniil
Mar 14, 2014, 9:16 AM
There is a JavaScript error "Ext is not defined". It means that the JavaScript resources not loaded before "Ext.onReady".

Please put the ResourceManager into the <form>, then it should be OK.

tMp
Mar 14, 2014, 9:56 AM
I put it there because of a problem I once had a long time ago and the solution was to put it there. Don't even know if I need it anymore ;) Have to check it out.

Thank you very much. I consider this matter resolved.