PDA

View Full Version : [CLOSED] [#1452] [4.2.0] DatePickerField set date value from view causes NullReferenceException



unicorn64
Mar 23, 2017, 7:37 AM
Hi all,
I try to set DatePickerField's DateValue from view, to set a default date value
but it gives NullReferenceException..



@using Ext.Net.Mobile;
@using Ext.Net.Mobile.MVC;


@{
Layout = null;
var X = Html.X();
}

<!DOCTYPE html>

<html>
<head>
<title>Ext.NET Mobile MVC Sample</title>
</head>
<body>
@X.ResourceManager().Theme(Theme.Neptune);


@(X.Viewport()
.Layout(LayoutType.VBox)
.Padding(10)
.Items(
X.DatePickerField().Label("Tarih").DateValue(DateTime.Today)
)
)
</body>
</html>

fabricio.murta
Mar 24, 2017, 1:36 AM
Hello @unicorn64!

Thanks for reporting the issue!

Seems there are problems on Ext.NET side -and- ExtJS's. ExtJS manual is not clear on which value type should be used there also, but seems passing a JavaScript Date() object does the trick!

Try this:



.CustomConfig(c =>
{
c.Add(new ConfigItem()
{
Name = "value",
Value = String.Format("new Date({0}, {1}, {2})", DateTime.Today.Year, DateTime.Today.Month - 1, DateTime.Today.Day),
Mode = ParameterMode.Raw
});
})


Instead of [var].DateValue(...)[/b].

This should get you up and running for the time being. And won't just break on next release either. (at least immediate next release 4.2.0 based on ExtJS 6.2.1!)

ExtJS 6.2.1 (1) manual claims it can be specified in the following format :



value: { year: 2017, month: 3, day: 23 },


But it didn't work at all, new version of ExtJS seems to also support only and only the JS Date() object parameter.

We've just created issue #1452 (https://github.com/extnet/Ext.NET/issues/1452) to track this defect. As soon as we fix it, we'll post a follow-up here!

Notes:
(1): current Ext.NET is based on ExtJS 6.0.2, and we're currently working on setting up Ext.NET with ExtJS 6.2.1!

fabricio.murta
Mar 24, 2017, 2:45 AM
Hello again, @unicorn64!

Well, looks like the fix was not really tough! We have just fixed and it will be available on the upcoming 4.2.0 release, so stay tuned!

For premium subscription users, the fix would already be available, but it has been made in the branch we are merging ExtJS 6.2.1 (unstable), but it would be easy to cherry-pick the change to current master if anyone needed this fixed immediately!

Thanks again for reporting us the issue! Looking forward to your feedback about the workaround provided!