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

[Solved] MVC grid ajax update/delete causes 'dateTimeFormat' is null or not an object

7 Answers 227 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Pak
Top achievements
Rank 1
Pak asked on 22 Mar 2011, 12:21 PM
Hi

Version that we are using is: 2011.1.315.

We are completely stuck with this error and have no idea why we encounter this null exception javascript error. We are very much appreciated if anyone please shed some light.

We have a MVC grid that has been configured to use ajax update and delete as shown below. Whenever we perform an update or delete, the ajax update is always canceled due to a javascript null exception error in MicrosoftAjax.js, .  

The offending line is: var b=j.dateTimeFormat

The call before the above line is from jquery-1.5.1.min.js as shown below:

b=d.isFunction(b)?b():b,e[e.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)

where
1/ encodeURIComponent(a) = "Product%5BStartDate%5D%5B_toFormattedString%5D"
2/ e.length = 23

and e has the following values:

e[0] = "ShoppingCartLineID=123"
e[1] = "ShoppingCartHeaderID=0"
e[2] = "ProductID=0"
e[3]= "Quantity=1"
e[4] = "IsDeleted=false"
e[5] = "Product%5BProductID%5D=1"
e[6] = "Product%5BProductSKU%5D=X238473"
e[7] = "Product%5BSupplierSKU%5D=123456789"
e[8] = "Product%5BSupplierProductUrl%5D=null"
e[9] = "Product%5BSupplierID%5D=null"
e[10] = "Product%5BCategoryID%5D=0"
e[11] = "Product%5BFinishedGoodsFlag%5D=true"
e[12] = "Product%5BColourID%5D=null"
e[13] = "Product%5BSizeID%5D=null"
e[14] = "Product%5BUnitPrice%5D=25.9"
e[15] = "Product%5BCostPrice%5D=3"
e[16] = "Product%5BResellerUnitPrice%5D=3.25"
e[17] = "Product%5BTaxIncluded%5D=true"
e[18] = "Product%5BIsTaxableProduct%5D=true"
e[19] = "Product%5BIsOverrideDefaultTax%5D=false"
e[20] = "Product%5BOverrideTaxRate%5D=0"
e[21] = "Product%5BCurrencyID%5D=0"
e[22] = "Product%5BCurrencyCode%5D=AUD"

Product Start Date has this value: Fri Jan 1 00:00:00 UTC+1100 2010

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<XXXXXX.Services.Model.ShoppingCartLine>>" %>
 
<% Html.Telerik().Grid<XXXXXX.Services.Model.ShoppingCartLine>()
    .Name("ShoppingCartList")
    .Editable(e => e.DisplayDeleteConfirmation(true).Mode(GridEditMode.InLine))
    .DataKeys(d =>
        {
            d.Add(x => x.ShoppingCartLineID);
        })
    .DataBinding(dataBinding => dataBinding.Ajax()
        .Update("UpdateCustomerShoppingCartByAjax", "OrderOnline")
        .Delete("DeleteCustomerShoppingCartLineByAjax", "OrderOnline")
        .Select("SelectCustomerShoppingCartLineByAjax", "OrderOnline")
    )
    .ClientEvents(evt => evt.OnDataBound("refreshFooter"))
    .Columns(columns =>
        {
            columns.Bound(c => c.Product.InternalFileName)
                .ClientTemplate("<img width='50' height='50' alt='<#= Product.InternalFileName #>' src='"
                    + Url.Content("~/Content/images/")
                    + "<#= Product.InternalFileName #>' />").Title("").ReadOnly().Width("70px");
            columns.Bound(c => c.Product.ProductModel.Name).ReadOnly().Width("300px");
            columns.Bound(c => c.QuantityInInt).Width("80px")
                .Title("Quantity")
                .HtmlAttributes(new { @class = "order-line" })
                .HeaderHtmlAttributes(new { @style = "text-align: right" });
            columns.Bound(c => c.Product.UnitPriceWithDiscount).Format("{0:c}").Width("80px").ReadOnly()
                .Title("Price")
                .HeaderHtmlAttributes(new { @style = "text-align: right" })
                .FooterTemplate("Total")
                .HtmlAttributes(new { @class = "order-line" })
                .FooterHtmlAttributes(new { @class = "order-footer" });
            columns.Bound(c => c.LineTotal).Format("{0:c}").Width("100px").ReadOnly()
                .Title("Total")
                .HeaderHtmlAttributes(new { @style = "text-align: right" })
                .FooterTemplate("<div id='footerTotal' />")
                .HtmlAttributes(new { @class = "order-line" })
                .FooterHtmlAttributes(new { @class = "order-footer" });
            columns.Bound(c => c.LineNote).Width("100px").Title("Notes");
            columns.Command(command =>
                {
                    command.Edit().ButtonType(GridButtonType.ImageAndText);
                    command.Delete().ButtonType(GridButtonType.ImageAndText);
                }).Width("100px");
        }
    )
    .Pageable(p => p.PageSize(50).Position(GridPagerPosition.Both))
    .Render();
        
%>

Thank you

7 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 22 Mar 2011, 01:11 PM
Hello Pak,

Can you please download the latest internal build from your account and see if it makes any difference in the observed behavior.

All the best,
Rosen
the Telerik team
0
Pak
Top achievements
Rank 1
answered on 22 Mar 2011, 01:24 PM
Hi Rosen

Thanks for your prompt reply. After posting the article, we realized that was an internal build and downloaded it. Unfortunately, it is still the same error. It seems to me it is a date time format issue and stuck at that Product Start Date.

Thank you
Best regards
Pak
0
Rosen
Telerik team
answered on 22 Mar 2011, 01:40 PM
Hi Pak,

In such case can you please provide a small runnable project in which the issue can be observed. This will allow us to debug it locally and provide you with more to-the-point answer.

Regards,
Rosen
the Telerik team
0
Pak
Top achievements
Rank 1
answered on 22 Mar 2011, 02:48 PM
Hi Rosen

Please kindly find attached the project that demonstrates the issue.

Thank you and look forward to hearing from you.
Best regards
Pak


0
Accepted
Rosen
Telerik team
answered on 23 Mar 2011, 08:38 AM
Hi Pak,

Thank you for sending us the sample project. I was able to observed the error you have described.
We were able to find the cause for the error and I'm attaching an internal build which should address it.

All the best,
Rosen
the Telerik team
0
Pak
Top achievements
Rank 1
answered on 23 Mar 2011, 11:57 AM
Hi Rosen

Thank you and much appreciated for your help. Yes it fixes the issue.

Cheers
Pak
0
Darren
Top achievements
Rank 1
answered on 17 May 2011, 05:13 PM
In case someone else runs into this, I found a simple solution at http://www.telerik.com/community/forums/aspnet-mvc/datepicker/datepicker-value-in-ajax-post.aspx#1360193.

-Darren
Tags
Grid
Asked by
Pak
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Pak
Top achievements
Rank 1
Darren
Top achievements
Rank 1
Share this question
or