jquery - Created a Function for a selected row in a grid -
my grid bined ajax call, when select row edit there field named "device_type",i want send value of selected row device type using ajax fill dropdown list in pop editor,how can write function that?
$("#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(); } });
if you're providing ability select single row, function below return array of columns , assigned values.
$("#turbingrid").click(function(){ var grid = $("#grid").data("kendogrid"); var selecteditem = grid .datasource._data console.log(selecteditem); }); see dojo working example of implementation... http://dojo.telerik.com/eperoq
edit (to accommodate question):
function select(e){ var selected = $.map(this.select(), function(item) { return $(item); }); console.log(selected) } your grid creation should this
$("#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(); } }); edit 2: looked around demos too, see dojo modified might idea of how implement event. make sure open developer tools see console.log http://dojo.telerik.com/osihu
Comments
Post a Comment