3 일 동안 작업했지만 문제가 발생했지만 해결책을 찾을 수 없습니다 !!! 은 document.ready에서는 전 서브 오브젝트kendoGrid에서 레코드를 추가 할 수 없습니다.
var datasource = [
{
"category": {
"id_category": 1,
"desc_category": "Beverages"
},
"id_product": 1,
"desc_product": "Chai",
"price": "11",
"id_category": 1
},
{
"category": {
"id_category": 2,
"desc_category": "Condiments"
},
"id_product": 2,
"desc_product": "Aniseed Syrup",
"price": "12",
"id_category": 2
}
]
하고 난 편집 모드 표에서 콤보 박스를 채우는
var kendoGrid = $("#grid").kendoGrid({
selectable: true,
dataSource: datasource,
resizable: true,
toolbar: [{
name: "create",
text: "Add Something"
}],
columns: [
{ field: "desc_product", title: "Description", width: 100 },
{ field: "price", title: "Price", width: 100 },
{ field: "id_product", title: "Category", width: 200, editor: categoryDropDownEditor, template: '#=category.desc_category#' },
{
command: [{
name: "destroy",
text: "Delete",
confirmation: "Are you sure?"
},
{
name: "edit",
text: {
edit: "Edit",
update: "Update",
cancel: "Cancel"
}
}
]
}
],
width: 200,
height: 300,
editable: editable = {
mode: "inline",
confirmation: "Are you sure?"
}
});
마침내 기능 kendogrid를 생성과 데이터 소스를 생성
function categoryDropDownEditor(container, options) {
var ds = [
{
"id_category": 1,
"desc_category": "Beverages"
},
{
"id_category": 2,
"desc_category": "Condiments"
},
{
"id_category": 3,
"desc_category": "Confections"
},
{
"id_category": 4,
"desc_category": "Produce"
},
{
"id_category": 5,
"desc_category": "Sea Food"
}
];
$('<input data-text-field="desc_category" data-value-field="id_category" data-bind="value:' + options.field + '"/>"')
.appendTo(container)
.kendoComboBox({
index: 0,
placeholder: "Select Category",
dataTextField: "desc_category",
dataValueField: "id_category",
dataSource: ds
})
}
새 레코드를 추가하려고하면 오류가 발생합니다 (런타임 오류 : 범주는 정의되지 않음).
데이터 소스가 맞는지 누군가가 알 수 있습니까? 코드의 구조가 맞습니까? 어디에 문제가 있습니까?
누군가 나를 도울 수 있기를 바랍니다 !!!
나는 같은 문제가 있지만 실제로 classe_iva 무엇이며 그것을 선언하는 방법을 얻지 못하겠습니까? 도움이 될만한 표본이 있습니까? – Gabriel