剑道网格错误-网格.选择不是函数为什么
Error in kendo grid - grid.select is not a function why?
我有一个kendoDropDown列表作为我的网格单元格。我正在使用剑道网格("编辑器")的编辑器命令调用kendDropDownList。我需要将选定行的选定值传递给kendoDropDownList作为参数,以便服务器仅以过滤列表作为我的kendoDropDownList回复。请看下面的例子
var grid = $("#grid").kendoGrid({
dataSource: dataSource,
pageable: true,
columnMenu:true,
filterable:true,
height: 550,
reorderable: true,
columnReorder: function(e) {
console.log(e.column.field, e.newIndex, e.oldIndex);
},
toolbar: ["create","excel","save", "cancel" , { template: kendo.template($("#template").html()) } , { template: kendo.template($("#clearFilterTemplate").html()) } , { name: "create", text: "Add New Employee" }],
excel: {
fileName: "Kendo UI Grid Export.xlsx",
proxyURL: "excelExport",
filterable: true,
allPages: true
},
editable: "inline" , //editable: true,
columns: [
{ field: "fileNo" , title:"File No" , width: 80 },
{ field: "jobNo" , title:"Job No" , width: 80 },
{ field: "discipline" , title:"Discipline" , width: 80 },
{ field: "moduleNo" ,title:"Module", width: 100},
{ field: "description",title:"Title",editor: descriptionDropDownEditor, width: 150},
{ field: "documentNo",title:"Document No", width: 150 },
{ field: "remarks",title:"Remarks" , width: 150 } ,
{ command: ["edit","destroy"], title: " ", width: "250px" }
]
});
function descriptionDropDownEditor(container, options) {
// here is the error grid.select is not a function why ?
var selectedItem = grid.dataItem(grid.select());
var selectedJobNo = selectedItem.jobNo ;
alert("selectedJobNo :"+selectedJobNo );
$('<input required name="' + options.field + '"/>')
.appendTo(container)
.kendoDropDownList({
autoBind: false,
dataTextField: "text",
dataValueField: "value",
filter: "contains",
dataSource: {
dataType: "json",
transport: {
// I need to pass the selected jobNo in order to get the only aprropriate descrption for that jobNo
// each row job has description and I don't want to show all the description for all jobs , I need only for that row jobNo
read: "getDescriptionForEachDocumentIndex?selectedJobNo"+selectedJobNo
}
}
});
}
一旦网格行处于编辑模式,我需要将选中的行jobNo传递给kendoDropDownList,以便仅用该jobNo的相关描述进行响应。问题是我不能在编辑模式下调用网格,并使用函数grid.select()。在这种情况下该怎么做?
这很简单。编辑器函数的第二个参数有一个名为model的属性,它是用户正在编辑的当前行的dataItem。所以在你的情况下,我想这是可行的:
function descriptionDropDownEditor(container, options) {
var selectedItem = options.model;
但是,要回答您的问题,您不能访问select()
方法,因为grid
不是剑道网格对象,它实际上是#grid
元素。您可以在小部件初始化的末尾添加.data("kendoGrid")
:
$("#grid").kendoGrid({ ... }).data("kendoGrid");
或者在函数内部调用:
function descriptionDropDownEditor(container, options) {
var gridWidget = $(grid).data("kendoGrid");
var selectedItem = gridWidget.dataItem(gridWidget.select());
相关文章:
- 将模型从Kendo Mvc UI网格传递到javascript函数
- UI网格:如何从自定义函数访问MODEL_COL_FIELD
- 在剑道网格中,我可以用一个函数动态设置列属性吗
- 在剑道网格模板中使用Javascript函数
- 渲染的Angular ui网格的回调函数
- 在多个网格视图/表上使用相同的函数
- Kendo mvc网格客户端模板javascript函数不起作用
- 加载网格后调用 Jquery 函数 asp.net
- 使用 KendoUI 网格小部件使用本地数据实现 CRUD 函数
- jQuery 引导网格排序函数不一致
- 如何在调用 setSource() 函数后重绘或更新 extjs 网格的宽度/高度
- jq网格编辑自定义函数
- 网格器不使用回调函数
- Javascript 函数调用在网格视图中不起作用
- 具有剑道网格刷新的回调函数
- ExtJs 4.2, 网格中继来自存储加载事件的事件导致未捕获的类型错误: 未定义不是一个函数
- 当存在角度时,Kendo UI 网格无法从 jquery 初始化 - 抛出“undefined 不是函数”
- 具有层次结构的网格自定义命令正在调用 javascript 函数两次
- 如何在不使用剑道层次结构网格中的详细初始化函数的情况下获取第一个孩子的兄弟姐妹
- jqGrid:网格函数只执行一次