Question

I'm having an issue with a grid. When I hit the edit button to edit a row's contents, I get the following javascript error:

Line: 1 Error: 'data(...)' is null or not an object

The error points back to telerik.grid.editing.min.js. I have done inline editing in other parts of my site, however, this one for some reason is spitting up this error. Here is my partial view that the code rests in.

@model CycleCountModel
@using Telerik.Web.Mvc.UI;

<div id="divGrid">
    @(Html.Telerik().Grid<CycleCountProductModel>()
        .Name("cyclecountproducts-grid")
        .DataKeys(keys =>
        {
            keys.Add(x => x.CycleCountId);
        })
        .DataBinding(dataBinding =>
        {
            dataBinding.Ajax()
                .Select("_CycleCountProductGrid", "CycleCount", Model)
                .Update("_CycleCountProductUpdate", "CycleCount")
                .Delete("_CycleCountProductDelete", "CycleCount");
        })
        .ClientEvents(events =>
        {
            events
                .OnDataBinding("onDataBinding");
        })
        .Columns(columns =>
        {
            columns.Bound(x => x.CycleCountId)
                .Hidden(true);
            columns.Bound(x => x.ProductId)
                .Hidden(true);
            columns.Bound(x => x.ItemNumber)
                .ReadOnly(true);
            columns.Bound(x => x.ProductName)
                .ReadOnly(true);
            columns.Bound(x => x.CategoryName)
                .ReadOnly(true);
            columns.Bound(x => x.PrimaryLocation)
                .ReadOnly(true);
            if (Model.Id == 0)
            {
                columns.Bound(x => x.LastCountedDate)
                    .ReadOnly(true);
            }
            if (Model.Id != 0)
            {
                columns.Bound(x => x.Sublocations)
                    .ReadOnly(true);
                columns.Bound(x => x.Measure)
                    .ReadOnly(true);
                columns.Bound(x => x.SystemStockQuantity)
                    .ReadOnly(true);
                columns.Bound(x => x.ShelfStockQuantity);
                if (Model.Status == 1)
                {
                    columns.Command(commands =>
                    {
                        commands.Edit();
                        commands.Delete();
                    });
                }
            }
        })
        .Pageable()
        .EnableCustomBinding(true))
</div>

Compared to my past work, this is similar. The only difference I really have is where I'm showing pieces of the grid (this grid is reused in other areas of the site, hence why checking the status). Some direction would be much appreciated.

Was it helpful?

Solution

I found the problem. Where I have my CycleCountId and ProductId, I have them only as hidden. When I added a Readonly to them, the error went away. It makes sense now that I think about it. However, it is annoying to say the least.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top