HI,,
i am try to use grid view with inline editing function.
now i have write this code:-- on cshtml.
<script>
$(document).ready(function () {
$("#countryzone-grid").kendoGrid({
dataSource: {
type: "json",
transport: {
read: {
url: "@Html.Raw(Url.Action("ParticipatingCountry", "Program", new {id = Model.Id } ))",
type: "POST",
dataType: "json",
contentType: "application/json"
},
create: {
url: "@Html.Raw(Url.Action("EditCountries", "Program"))",
type: "POST",
dataType: "json"
},
update: {
url:"@Html.Raw(Url.Action("SettingUpdate", "Setting"))",
type: "POST",
dataType: "json"
},
destroy: {
url: "@Html.Raw(Url.Action("SettingDelete", "Setting"))",
type: "POST",
dataType: "json"
},
parameterMap: function(data, operation) {
if (operation != "read") {
return data;
} else {
//for some reasons only such "Filter" data be parsed
return JSON.stringify(data);
}
}
},
schema: {
data: "Data",
total: "Total",
errors: "Errors",
model: {
id: "Id",
fields: {
CountryId: { editable: true, type: "number" },
CountryName: { editable: true, type: "string"},
PointsValue: { editable: true, type: "number"},
Id: { editable: false, type: "number" },
ProgramId: { editable: false, type: "number" }
}
}
},
requestEnd: function (e) {
if (e.type == "create" || e.type == "update") {
this.read();
}
},
error: function (e) {
display_kendoui_grid_error(e);
// Cancel the changes
this.cancelChanges();
},
pageSize: 5,
serverPaging: true,
serverFiltering: true,
serverSorting: true
},
pageable: {
refresh: true
},
sortable: true,
toolbar: ["create"],
editable: {
confirmation: false,
mode: "inline"
},
scrollable: false,
columns:[{
field: "CountryId",
title: "Admin.Program.participatingCountryName",
editor: countryDropDownEditor,
template: "#:Store#"
},{
field: "PointsValue",
title: "Admin.Program.PointsValue"
},{
command: ["edit", "destroy"], title: "",width: "200px"
}]
});
});
function countryDropDownEditor(container, options) {
$('<input required data-text-field="Name" data-value-field="Id" data-bind="value:CountryId"/>')
.appendTo(container)
.kendoDropDownList({
autoBind: false,
dataTextField: "Name",
dataValueField: "Id",
dataSource: {
type: "json",
transport: {
read: {
dataType: "json",
type: 'POST',
url:
"@Html.Raw(Url.Action("DropDownListCountries", "Program", new {id =
Model.ClientId } ))"
}
}
}
});
}
</script>
by this code when i click on update button there is an ajax call
this is data of post tab in ajax call ( view on browser by firebug)
CountryId 0
CountryName
Id 0
PointsValue 2
ProgramId 0
there is data 0 and 2
on controlller side my code is
[HttpPost]
public ActionResult EditCountries([Bind(Exclude = "Id")] ParticipatingCountryModel model) <== Here i put break point
{
return null;
}
by break point i see that there is ajax call come means action call but there is an empty model ,,, alll values are 0, there is an value 2 but there is 0 why?
is am i doing wrong?
Please advice how to do?
Regard,
vinit
i am try to use grid view with inline editing function.
now i have write this code:-- on cshtml.
<script>
$(document).ready(function () {
$("#countryzone-grid").kendoGrid({
dataSource: {
type: "json",
transport: {
read: {
url: "@Html.Raw(Url.Action("ParticipatingCountry", "Program", new {id = Model.Id } ))",
type: "POST",
dataType: "json",
contentType: "application/json"
},
create: {
url: "@Html.Raw(Url.Action("EditCountries", "Program"))",
type: "POST",
dataType: "json"
},
update: {
url:"@Html.Raw(Url.Action("SettingUpdate", "Setting"))",
type: "POST",
dataType: "json"
},
destroy: {
url: "@Html.Raw(Url.Action("SettingDelete", "Setting"))",
type: "POST",
dataType: "json"
},
parameterMap: function(data, operation) {
if (operation != "read") {
return data;
} else {
//for some reasons only such "Filter" data be parsed
return JSON.stringify(data);
}
}
},
schema: {
data: "Data",
total: "Total",
errors: "Errors",
model: {
id: "Id",
fields: {
CountryId: { editable: true, type: "number" },
CountryName: { editable: true, type: "string"},
PointsValue: { editable: true, type: "number"},
Id: { editable: false, type: "number" },
ProgramId: { editable: false, type: "number" }
}
}
},
requestEnd: function (e) {
if (e.type == "create" || e.type == "update") {
this.read();
}
},
error: function (e) {
display_kendoui_grid_error(e);
// Cancel the changes
this.cancelChanges();
},
pageSize: 5,
serverPaging: true,
serverFiltering: true,
serverSorting: true
},
pageable: {
refresh: true
},
sortable: true,
toolbar: ["create"],
editable: {
confirmation: false,
mode: "inline"
},
scrollable: false,
columns:[{
field: "CountryId",
title: "Admin.Program.participatingCountryName",
editor: countryDropDownEditor,
template: "#:Store#"
},{
field: "PointsValue",
title: "Admin.Program.PointsValue"
},{
command: ["edit", "destroy"], title: "",width: "200px"
}]
});
});
function countryDropDownEditor(container, options) {
$('<input required data-text-field="Name" data-value-field="Id" data-bind="value:CountryId"/>')
.appendTo(container)
.kendoDropDownList({
autoBind: false,
dataTextField: "Name",
dataValueField: "Id",
dataSource: {
type: "json",
transport: {
read: {
dataType: "json",
type: 'POST',
url:
"@Html.Raw(Url.Action("DropDownListCountries", "Program", new {id =
Model.ClientId } ))"
}
}
}
});
}
</script>
by this code when i click on update button there is an ajax call
this is data of post tab in ajax call ( view on browser by firebug)
CountryId 0
CountryName
Id 0
PointsValue 2
ProgramId 0
there is data 0 and 2
on controlller side my code is
[HttpPost]
public ActionResult EditCountries([Bind(Exclude = "Id")] ParticipatingCountryModel model) <== Here i put break point
{
return null;
}
by break point i see that there is ajax call come means action call but there is an empty model ,,, alll values are 0, there is an value 2 but there is 0 why?
is am i doing wrong?
Please advice how to do?
Regard,
vinit