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

handling error on grid add/update

0 Answers 101 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kristin
Top achievements
Rank 1
Kristin asked on 18 Oct 2012, 02:48 PM
I am working on adding and editing items on my grid and occasionally I will get an error back from the server if there is a problem with the submission (i.e. username already exists, etc.).  I would like to handle this error gracefully and let the user re-edit the line and re-submit the changes.  Right now, it just looks like it changes in the grid but it doesn't actually update.

Here is what I have:
$("#tblCompanies").kendoGrid({
    dataSource: new kendo.data.DataSource({
        type: "json",
        transport: {
            read: {
                url: "http://192.168.1.33:8090/pumpSystem/getProdCompanyList",
                dataType: "json",
                type: "GET"
            },
            update: {
                url: "http://192.168.1.33:8090/pumpSystem/updateProductionCompany",
                dataType: "json",
                type: "POST"
            },
            create: {
                url: "http://192.168.1.33:8090/pumpSystem/addProductionCompany",
                dataType: "json",
                type: "POST"
            }
        },
        schema: {
            model: {
                id: "Id",
                fields: {
                    Id: { type: "number", editable: false },
                    CompanyId: { type: "number", validation: { required: true, min: 1} },
                    Name: { type: "string", validation: { required: true} },
                    isEnabled: { type: "boolean" }
                }
            }
        }
 
    }),
    columns: [
        { field: "CompanyId", title: "CompanyID", width: "60px" },
        { field: "Name", title: "Name", width: "150px" },
        { field: "isEnabled", title: "Enabled", width: "60px" },
        { command: ["edit"], width: "150px" }
    ],
    editable: "inline",
    toolbar: ["create"]
 
});

If there is an error on the add or update then I will get a JSON response from the server -- some thing like this: 

"[{'error','CompanyId already in system'}]"

Any ideas on how I can use the datasource and/or grid to process this error response and allow the user to re-edit??

Thanks so much!!!

No answers yet. Maybe you can help?

Tags
Grid
Asked by
Kristin
Top achievements
Rank 1
Share this question
or