Jquery 为网格中的选定行创建函数
我的网格与ajax调用结合在一起,当我选择要编辑的行时,有一个名为“Device_Type”的字段,我想使用ajax发送我选择的行Device Type的值,以填充弹出编辑器中的下拉列表,我如何为其编写函数Jquery 为网格中的选定行创建函数,jquery,kendo-ui,kendo-grid,Jquery,Kendo Ui,Kendo Grid,我的网格与ajax调用结合在一起,当我选择要编辑的行时,有一个名为“Device_Type”的字段,我想使用ajax发送我选择的行Device Type的值,以填充弹出编辑器中的下拉列表,我如何为其编写函数 $("#turbingrid").kendoGrid({ // debugger; dataSource: dataSource, scr
$("#turbingrid").kendoGrid({
// debugger;
dataSource: dataSource,
scrollable: false,
columns: [
{ field: 'DeviceIP', title: 'DeviceIP', width: '100px', id: 'DeviceIP' },
{ field: 'Producer', title: 'Producer', width: '80px', editor: ProductNameDropDownEditor, },
{ field: 'Model', title: 'Model', width: '220px' },
{ field: 'DeviceType', title: 'DeviceType', width: '100px',editor: deviceTypesList },
{ field: 'Description', title: 'Description', width: '220px' },
{ field: 'Username', title: 'Username', width: '120px' },
{ field: 'Password', title: 'Password', width: '100px' },
{ field: 'PublicIP', title: 'PublicIP', width: '120px' },
{ field: 'device_id', title: 'device_id', width: '120px',hidden:true },
{ command: ["edit"], title: " " }],
editable: "popup",
//edit:
// function () {
// document.getElementsByName("DeviceIP")[0].disabled = true;
// },
edit: function(e) {
e.container.find("label[for='device_id']").parent().hide();
e.container.find("div[data-container-for='device_id']").hide();
}
});
如果您只提供选择单行的功能,下面的my函数将返回一个列数组及其赋值
$("#turbingrid").click(function(){
var grid = $("#grid").data("kendoGrid");
var selectedItem = grid .dataSource._data
console.log(selectedItem);
});
请参阅Dojo和我的实现的工作示例。。。
编辑(以容纳问题):
您的网格创建应该如下所示
$("#turbingrid").kendoGrid({
// debugger;
dataSource: dataSource,
scrollable: false,
columns: [
{ field: 'DeviceIP', title: 'DeviceIP', width: '100px', id: 'DeviceIP' },
{ field: 'Producer', title: 'Producer', width: '80px', editor: ProductNameDropDownEditor, },
{ field: 'Model', title: 'Model', width: '220px' },
{ field: 'DeviceType', title: 'DeviceType', width: '100px',editor: deviceTypesList },
{ field: 'Description', title: 'Description', width: '220px' },
{ field: 'Username', title: 'Username', width: '120px' },
{ field: 'Password', title: 'Password', width: '100px' },
{ field: 'PublicIP', title: 'PublicIP', width: '120px' },
{ field: 'device_id', title: 'device_id', width: '120px',hidden:true },
{ command: ["edit"], title: " " }],
editable: "popup",
selectable : true,
change : select,
//edit:
// function () {
// document.getElementsByName("DeviceIP")[0].disabled = true;
// },
edit: function(e) {
e.container.find("label[for='device_id']").parent().hide();
e.container.find("div[data-container-for='device_id']").hide();
}
});
编辑2:
也只是看看演示,看看我稍微修改过的Dojo,因为它可能会帮助您了解如何实现此事件。确保打开开发人员工具以查看console.log
如何在以下链接的弹出编辑器中获取“ProductName”的值
$("#turbingrid").kendoGrid({
// debugger;
dataSource: dataSource,
scrollable: false,
columns: [
{ field: 'DeviceIP', title: 'DeviceIP', width: '100px', id: 'DeviceIP' },
{ field: 'Producer', title: 'Producer', width: '80px', editor: ProductNameDropDownEditor, },
{ field: 'Model', title: 'Model', width: '220px' },
{ field: 'DeviceType', title: 'DeviceType', width: '100px',editor: deviceTypesList },
{ field: 'Description', title: 'Description', width: '220px' },
{ field: 'Username', title: 'Username', width: '120px' },
{ field: 'Password', title: 'Password', width: '100px' },
{ field: 'PublicIP', title: 'PublicIP', width: '120px' },
{ field: 'device_id', title: 'device_id', width: '120px',hidden:true },
{ command: ["edit"], title: " " }],
editable: "popup",
selectable : true,
change : select,
//edit:
// function () {
// document.getElementsByName("DeviceIP")[0].disabled = true;
// },
edit: function(e) {
e.container.find("label[for='device_id']").parent().hide();
e.container.find("div[data-container-for='device_id']").hide();
}
});