I know that you can apply a template to a field in the grid to display an empty string instead of a null, but can you do the same thing for the resulting field in the popup edit window? The following is what I have, but is filling the Address2 textbox with 'null' when the popup is displayed.
$(document).ready(function () {
dataSource = new kendo.data.DataSource({
transport: {
read: {
url: "@Url.Action("Read", "Address")"
},
update: {
url: "@Url.Action("Update", "Address")",
type: "POST",
complete: function(data) {
$('#grid').data('kendoGrid').dataSource.read();
alert("Address successfully updated");
}
},
parameterMap: function(data, operation) {
if (operation != "read") {
// post the products so the ASP.NET DefaultModelBinder will understand them:
var result = {};
for (var i = 0; i < data.models.length; i++) {
var address = data.models[i];
}
return address;
}
}
},
batch: true,
pageSize: 30,
schema: {
model: {
id: "AddressID",
fields: {
AddressID: { editable: false, nullable: false },
Address: { type: "string", validation: { required: true} },
Address2: {
type: "string",
template: "#= (Address2 == 'null') ? ' ' : Address2 #"
},
City: { type: "string" },
State: { type: "string" },
Zip: { type: "string" },
}
}
}
});
$("#grid").kendoGrid({
dataSource: dataSource,
pageable: true,
height: 400,
columns: [
{ field: "Address", title: "Address", width: "250px" },
{ field: "Address2", title: "Address2", width: "200px"
, template: "#= (Address2 == 'null') ? ' ' : Address2 #"
},
{ field: "City", width: "100px" },
{ field: "State", width: "100px", maxlength: "2" },
{ field: "Zip", width: "100px" },
{ command: ["edit", "destroy"], title: " ", width: "210px"}],
editable: "popup"
});
});
$(document).ready(function () {
dataSource = new kendo.data.DataSource({
transport: {
read: {
url: "@Url.Action("Read", "Address")"
},
update: {
url: "@Url.Action("Update", "Address")",
type: "POST",
complete: function(data) {
$('#grid').data('kendoGrid').dataSource.read();
alert("Address successfully updated");
}
},
parameterMap: function(data, operation) {
if (operation != "read") {
// post the products so the ASP.NET DefaultModelBinder will understand them:
var result = {};
for (var i = 0; i < data.models.length; i++) {
var address = data.models[i];
}
return address;
}
}
},
batch: true,
pageSize: 30,
schema: {
model: {
id: "AddressID",
fields: {
AddressID: { editable: false, nullable: false },
Address: { type: "string", validation: { required: true} },
Address2: {
type: "string",
template: "#= (Address2 == 'null') ? ' ' : Address2 #"
},
City: { type: "string" },
State: { type: "string" },
Zip: { type: "string" },
}
}
}
});
$("#grid").kendoGrid({
dataSource: dataSource,
pageable: true,
height: 400,
columns: [
{ field: "Address", title: "Address", width: "250px" },
{ field: "Address2", title: "Address2", width: "200px"
, template: "#= (Address2 == 'null') ? ' ' : Address2 #"
},
{ field: "City", width: "100px" },
{ field: "State", width: "100px", maxlength: "2" },
{ field: "Zip", width: "100px" },
{ command: ["edit", "destroy"], title: " ", width: "210px"}],
editable: "popup"
});
});