so I recently created a grid called Regionmappinggrid, which has a datasource of RegionalMappingDataSource. What I'm trying to do is call the create function in the datasource from the toolbar element name create, but having no luck so far could some please help me out ? All of the code is below
var RegionalMappingDataSource = new kendo.data.DataSource({
transport: {
read: function(options) {
$.ajax({
url: siteRoot + '/Admin/RegionMapping/GetRegionMappings',
type: 'GET',
success: function(result) {
console.log(result);
options.success(result);
},
error: function(result) {
options.error(result);
}
});
},
create: function() {
console.log("hrllo00");
},
update: function () {
console.log("hello!");
},
parameterMap: function(options, operation) {
if (operation !== "read" && options.models) {
return { models: kendo.stringify(options.models) };
}
},
//schema: {
// model: {
// CountryName: { field: "CountryCode", type: "string" },
// CountryID:{"CountryId", type: "string" }
// RegionId: "RegionID",
// RegionOtherName: "Name",
// UpdatedDate: "UpdatedDate"
//}
//}
schema: {
model: {
id: "RegionMappingId"
//fields: {
// CountryId: { type: "number", editable: false},
// CountryCode: { type: "string", editable: true },
// RegionName: { type: "string", editable: true },
// RegionId: { type: "number", editable: true},
// Name: { type: "string", editable: true},
// UpdatedDate: { type: "date" }
//}
}
}
}
});
$("#Regionmappinggrid").kendoGrid({
sortable: true,
pageable: {
refresh: true,
pageSizes: true,
buttonCount: 5
},
editable: "inline",
toolbar: [{ name: "create", text: "Update Other Region Name" }],
columns: [
{
title: "Country Name",
field: "CountryCode",
editor: function(container, options) {
var input = $('<input required id="mapping" name="' + options.field + '"/>');
input.appendTo(container);
input.kendoDropDownList({
autoBind: true,
optionLabel: 'Please Select Country....',
dataTextField: "Value",
dataValueField: "Key",
dataSource: getCountryName,
value: options.model.Key,
text: options.model.Value
}).appendTo(container);
}
},
{
title: "Region Name",
field: "RegionName",
editor: function(container, options) {
var input = $('<input required id="mapping1" name="' + options.field + '"/>');
input.appendTo(container);
input.kendoDropDownList({
autoBind: false,
optionLabel: 'Please Select Region....',
dataTextField: "Value",
dataValueField: "Key",
dataSource: getRegionName,
value: options.model.Key,
text: options.model.Value
}).appendTo(container);
}
},
{
title: "Region ID",
field: "RegionId",
hidden: false
},
{
title: "Other Name",
field: "Name"
},
{
title: "Updated On",
field: "UpdatedDate",
format: "{0: yyyy-MM-dd HH:mm:ss}",
editable: function() { return false; }
},
{
command: ["edit", "destroy"]
}
],
dataSource: RegionalMappingDataSource