Hi,
I'm having a hard time making the DropDownListEditor work in a grid. I have seen other posts, but they don't seem to help. What am I missing?
[{"name":"eth0"},
{"name":"eth1"},
{"name":"eth2"},
{"name":"eth3"},
{"name":"eth4"}]
$(document).ready(function () {
var crudServiceBaseUrl = "http://127.0.0.1:8000/dhcp_client",
dataSource = new kendo.data.DataSource({
transport: {
read: {
url: crudServiceBaseUrl + "/server_load",
dataType: "json"
},
update: {
url: crudServiceBaseUrl + "/server_update",
dataType: "json",
type: "POST"
},
destroy: {
url: crudServiceBaseUrl + "/server_delete",
dataType: "json",
type: "POST"
},
create: {
url: crudServiceBaseUrl + "/server_add",
dataType: "json",
type: "POST"
},
parameterMap: function(options, operation) {
if (operation !== "read" && options.models) {
return {models: kendo.stringify(options.models)};
}
return true;
}
},
batch: true,
pageSize: 20,
schema: {
model: {
id: "id",
fields: {
nic: { field: "name", defaultValue: "eth0" },
rangestart: { validation: { required: true } },
rangeend: { validation: { required: true } },
gateway: { validation: { required: true } },
dns1: { validation: { required: true } },
dns2: { validation: { required: true } },
domain: { validation: { required: true } },
leasetime: { validation: { required: true } }
}
}
}
});
$("#tabstrip").kendoTabStrip({
animation: false // {
// open: {
// effects: "fadeIn"
// }
// }
});
$("#grid").kendoGrid({
dataSource: dataSource,
columnMenu: true,
sortable: true,
height: 200,
width: 500,
toolbar: ["create"],
columns: [
{ field: "nic", title: "Interface", width: "80px", editor: nicDropDownEditor},
{ field: "rangestart", title: "Range Start", width: 105 },
{ field: "rangeend", title: "Range End", width: 105 },
{ field: "gateway", title: "Gateway", width: 105 },
{ field: "dns1", title: "DNS1", width: 105 },
{ field: "dns2", title: "DNS2", width: 105 },
{ field: "domain", title: "Domain", width: 105 },
{ field: "leasetime", title: "Lease Time", width: 105 },
{ command: ["edit", "destroy"], title: " ", width: 160 }],
editable: "inline",
scrollable: "true"
});
});
function nicDropDownEditor(container, options) {
var input = $("<input/>");
input.attr("nic", options.field);
input.appendTo(container);
input.kendoDropDownList ({
autoBind: false,
dataTextField: "name",
dataSource: {
transport: {
read: "http://127.0.0.1/dhcp_client/interfaces_load",
type: "GET",
dataType: "json"
}
}
});
}
Thanks,
-G
I'm having a hard time making the DropDownListEditor work in a grid. I have seen other posts, but they don't seem to help. What am I missing?
[{"name":"eth0"},
{"name":"eth1"},
{"name":"eth2"},
{"name":"eth3"},
{"name":"eth4"}]
$(document).ready(function () {
var crudServiceBaseUrl = "http://127.0.0.1:8000/dhcp_client",
dataSource = new kendo.data.DataSource({
transport: {
read: {
url: crudServiceBaseUrl + "/server_load",
dataType: "json"
},
update: {
url: crudServiceBaseUrl + "/server_update",
dataType: "json",
type: "POST"
},
destroy: {
url: crudServiceBaseUrl + "/server_delete",
dataType: "json",
type: "POST"
},
create: {
url: crudServiceBaseUrl + "/server_add",
dataType: "json",
type: "POST"
},
parameterMap: function(options, operation) {
if (operation !== "read" && options.models) {
return {models: kendo.stringify(options.models)};
}
return true;
}
},
batch: true,
pageSize: 20,
schema: {
model: {
id: "id",
fields: {
nic: { field: "name", defaultValue: "eth0" },
rangestart: { validation: { required: true } },
rangeend: { validation: { required: true } },
gateway: { validation: { required: true } },
dns1: { validation: { required: true } },
dns2: { validation: { required: true } },
domain: { validation: { required: true } },
leasetime: { validation: { required: true } }
}
}
}
});
$("#tabstrip").kendoTabStrip({
animation: false // {
// open: {
// effects: "fadeIn"
// }
// }
});
$("#grid").kendoGrid({
dataSource: dataSource,
columnMenu: true,
sortable: true,
height: 200,
width: 500,
toolbar: ["create"],
columns: [
{ field: "nic", title: "Interface", width: "80px", editor: nicDropDownEditor},
{ field: "rangestart", title: "Range Start", width: 105 },
{ field: "rangeend", title: "Range End", width: 105 },
{ field: "gateway", title: "Gateway", width: 105 },
{ field: "dns1", title: "DNS1", width: 105 },
{ field: "dns2", title: "DNS2", width: 105 },
{ field: "domain", title: "Domain", width: 105 },
{ field: "leasetime", title: "Lease Time", width: 105 },
{ command: ["edit", "destroy"], title: " ", width: 160 }],
editable: "inline",
scrollable: "true"
});
});
function nicDropDownEditor(container, options) {
var input = $("<input/>");
input.attr("nic", options.field);
input.appendTo(container);
input.kendoDropDownList ({
autoBind: false,
dataTextField: "name",
dataSource: {
transport: {
read: "http://127.0.0.1/dhcp_client/interfaces_load",
type: "GET",
dataType: "json"
}
}
});
}
Thanks,
-G