New transport error on Grid edit

0 Answers 148 Views
Data Source Grid
Alex
Top achievements
Rank 1
Alex asked on 08 Mar 2022, 04:45 PM | edited on 08 Mar 2022, 04:58 PM

My company has a Kendo grid we use in an internal tool for changing settings. The way it's supposed to work, and has worked in the past, is that we change the entries in the grid using inline editors, but that there is no update, and then we have a "Save" button that gathers the settings from the grid and related data from a few other places and sends them off to the back end.

At some point, the team started to get an error, though nobody's sure when exactly; the Grid loads and reads without apparent issue, but when you try to edit anything, the Grid hangs and never recovers. If you click the "Save" button the change you made is uploaded just fine, but you couldn't make any other changes without refreshing the page.

Digging into the errors, the problem is that it's looking for "update" data in the transport and not finding it - the transport only defines "read". The thing is, it has never defined anything other than "read", including when it was most recently definitely working, and this tool is not supposed to update remotely on every edit (and previously quite happily did not). When I add an empty function as "update", just to see if I can get past it, it throws an "Unexpected Number" error.

The code changes that have been made since I last personally saw it working are:

- Added an ID column
- added an inline editor combo box

neither of which jump out at me as things that would prompt an update call that otherwise didn't happen. I have tried undoing all these changes and here has been no effect on the error.

var dataSource = new kendo.data.DataSource({
    pageSize: 500,
    autoSync: true,
    transport: {
        read: {
            url: String.format(readurl),
            data: {
                siteID: siteID
            },
            dataType: "json"
        }
    },
    schema: {
        model: {
            id: "SiteConfigItemID",
            fields: {
                SiteConfigItemID: { editable: false, nullable: true },
                ConfigurationType: {
                    defaultValue: { ConfigurationTypeID: 1, ConfigurationTypeName: "Default" }
                },
                KeyName: {
                    defaultValue: { ConfigurationKeyID: 1, ConfigurationKeyName: "Default" }
                },
                KeyValue: { validation: { required: true } },
                Locale: { validation: { required: true } },
                Ordinality: { validation: { required: false } }
            }
        },
        type: "json"
    }
});
$("#siteConfig").kendoGrid({
    dataSource: dataSource,
    autoBind: true,
    editable: true,
    pageable: {
        refresh: true,
        pageSizes: [15, 50, 100, 500]
    },
    scrollable: true,
    toolbar: ["create"],
    sortable: true,
    filterable: {
        extra: false,
        operators: {
            string: {
                startswith: "Starts with",
                contains: "Contains",
                doesnotcontain: "Doesn't contain",
                eq: "Is equal to",
                neq: "Is not equal to"
            }
        }
    },
    columns: [
        { field: "SiteConfigItemID", width: 100, title: "ID", hidden: true },
        { field: "ConfigurationType", width: 100, title: "Type", editor: typeDropDownEditor, template: "#=ConfigurationType.ConfigurationTypeName#" },
        { field: "KeyName", width: 200, title: "KeyName", editor: keyNameDropDownEditor, template: "#=KeyName.ConfigurationKeyName#" },
        { field: "KeyValue", width: 550, title: "" },
        { field: "Locale", width: 120, title: "" },
        { field: "Ordinality", width: 100, title: "" }]
});
dataSource.read();


Nikolay
Telerik team
commented on 11 Mar 2022, 12:50 PM

Hello Alex,

Thank you for sharing the Grid declaration.

I examined it and noticed the data source enables autoSync property. When set to true, the data source will automatically call the Update operation to save changed data items by calling the sync method right after a cell is edited. However, in your case, there is no Update operation and an error will appear in the console. Here is a Dojo demo demonstrating this:

I recommend disabling the autoSync. In case the issue remains please share the save logic you have for gathering the settings from the grid.

Regards,

Nikolay

 

Alex
Top achievements
Rank 1
commented on 18 Mar 2022, 10:58 AM

I have no idea why disabling a property which has not changed between the internal tool working and it not working has fixed this, but it absolutely has. Thank you very much. Now I just have to figure out why the obvious thing to cause this behaviour, that was in fact causing this behaviour, wasn't doing anything before.
Nikolay
Telerik team
commented on 23 Mar 2022, 09:21 AM

Hi Alex,

You are very welcome. I am happy to hear my suggestion resolved the situation.

As it comes to why this used to work correctly, I am not sure what the reason might be. If you happen to find out please keep me updated.

Regards,

nikolay

No answers yet. Maybe you can help?

Tags
Data Source Grid
Asked by
Alex
Top achievements
Rank 1
Share this question
or