Yo,
I'm using the KendoGrid, and there's a problem in my CRUD process. When I'm clicking to update button after editing data (in popup mode) in first time, the ajax call and the update in server works fine. But when I'm trying to edit an another row, the update ajax call runs twice, for this row, and the previous row. Here's my code:
var dataSource = new kendo.data.DataSource({
transport: {
create: {
url: GLOBALS.BASE_URL + "partner_editor_ajax/create",
dataType: "json",
type: "POST",
complete: function(e) {
dataSource.read();
}
},
read: {
url: GLOBALS.BASE_URL + "partner_editor_ajax/read",
dataType: "json",
type: "POST"
},
update: {
url: GLOBALS.BASE_URL + "partner_editor_ajax/update",
dataType: "json",
type: "POST",
complete: function(e) {
e.preventDefault();
}
},
destroy: {
url: GLOBALS.BASE_URL + "partner_editor_ajax/destroy",
dataType: "json",
type: "POST"
}
},
pageSize: 30,
batch: false,
schema: {
data: "results",
total: "results_per_page",
errors: "errors",
model: {
id: "_id",
fields: {
_id: { editable: false, nullable: false },
employeesNumber: { editable: false, nullable: true },
leaderName: {
editable: true,
validation: {
required: true,
pattern: "(.+){2,50}"
}
},
mailingAddress: {
editable: true,
validation: {
required: true,
pattern: "(.+){2,}"
}
},
name: {
editable: true,
validation: {
required: true,
pattern: "(.+){2,}"
}
},
taxNumber: {
editable: true,
validation: {
required: true,
pattern: "[0-9]{6,20}"
}
},
type: {
defaultValue: { value: "personal", text: "personal"},
editable: true,
validation: {
required: true,
pattern: "(.+){2,}"
}
},
website: { editable: true }
}
}
}
});
$("#grid").kendoGrid({
dataSource: dataSource,
pageable: true,
height: ($(window).height() - $("#header").height() - 4),
toolbar: ["create"],
columns: [
{
field: "employeesNumber",
title: Localization.get_localized_text("employees_number"),
width: "50px"
},
{
field: "leaderName",
title: Localization.get_localized_text("leader_name"),
width: "150px"
},
{
field: "mailingAddress",
title: Localization.get_localized_text("mailing_address"),
width: "200px"
},
{
field: "name",
title: Localization.get_localized_text("name"),
width: "150px"
},
{
field: "taxNumber",
title: Localization.get_localized_text("taxNumber"),
width: "150px"
},
{
field: "type",
title: Localization.get_localized_text("type"),
editor: typeDropDownEditor,
width: "100px"
},
{
field: "website",
title: Localization.get_localized_text("website"),
width: "100px"
},
{
command: ["edit"], title: " ", width: "60px"
},
{
command: ["destroy"], title: " ", width: "70px"
}
],
editable: {
mode: "popup"
}
});
Please help, what is the problem here?
Thank you in advance,
R
I'm using the KendoGrid, and there's a problem in my CRUD process. When I'm clicking to update button after editing data (in popup mode) in first time, the ajax call and the update in server works fine. But when I'm trying to edit an another row, the update ajax call runs twice, for this row, and the previous row. Here's my code:
var dataSource = new kendo.data.DataSource({
transport: {
create: {
url: GLOBALS.BASE_URL + "partner_editor_ajax/create",
dataType: "json",
type: "POST",
complete: function(e) {
dataSource.read();
}
},
read: {
url: GLOBALS.BASE_URL + "partner_editor_ajax/read",
dataType: "json",
type: "POST"
},
update: {
url: GLOBALS.BASE_URL + "partner_editor_ajax/update",
dataType: "json",
type: "POST",
complete: function(e) {
e.preventDefault();
}
},
destroy: {
url: GLOBALS.BASE_URL + "partner_editor_ajax/destroy",
dataType: "json",
type: "POST"
}
},
pageSize: 30,
batch: false,
schema: {
data: "results",
total: "results_per_page",
errors: "errors",
model: {
id: "_id",
fields: {
_id: { editable: false, nullable: false },
employeesNumber: { editable: false, nullable: true },
leaderName: {
editable: true,
validation: {
required: true,
pattern: "(.+){2,50}"
}
},
mailingAddress: {
editable: true,
validation: {
required: true,
pattern: "(.+){2,}"
}
},
name: {
editable: true,
validation: {
required: true,
pattern: "(.+){2,}"
}
},
taxNumber: {
editable: true,
validation: {
required: true,
pattern: "[0-9]{6,20}"
}
},
type: {
defaultValue: { value: "personal", text: "personal"},
editable: true,
validation: {
required: true,
pattern: "(.+){2,}"
}
},
website: { editable: true }
}
}
}
});
$("#grid").kendoGrid({
dataSource: dataSource,
pageable: true,
height: ($(window).height() - $("#header").height() - 4),
toolbar: ["create"],
columns: [
{
field: "employeesNumber",
title: Localization.get_localized_text("employees_number"),
width: "50px"
},
{
field: "leaderName",
title: Localization.get_localized_text("leader_name"),
width: "150px"
},
{
field: "mailingAddress",
title: Localization.get_localized_text("mailing_address"),
width: "200px"
},
{
field: "name",
title: Localization.get_localized_text("name"),
width: "150px"
},
{
field: "taxNumber",
title: Localization.get_localized_text("taxNumber"),
width: "150px"
},
{
field: "type",
title: Localization.get_localized_text("type"),
editor: typeDropDownEditor,
width: "100px"
},
{
field: "website",
title: Localization.get_localized_text("website"),
width: "100px"
},
{
command: ["edit"], title: " ", width: "60px"
},
{
command: ["destroy"], title: " ", width: "70px"
}
],
editable: {
mode: "popup"
}
});
Please help, what is the problem here?
Thank you in advance,
R