Greetings, I am not sure what's happening here, but I am unable to obtain data from a selected row in my code:
When my change function is triggered, my selected id is undefined. My guess is that I have a misunderstanding somewhere in my data modelling or something of that nature.
Any hints would be appreciated, thank you very much!
var selectedActivity;var activityModel = kendo.data.Model.define({ id: "_id", fields: { _id : {type:"string"}, date: {type:"string"}, activity : {type:"string"}, hours : {type:"number"} }});dataSource = new kendo.data.DataSource({ transport: { read: { url: '/activity', contentType: 'application/json; charset=utf-8', type: 'GET', dataType: 'json' }, destroy: { url: '/activity', type: 'DELETE', dataType: 'json' }, update: { url: '/activity', type: 'PUT', dataType: 'json' }, }, schema:{ model: activityModel }});$("#grid").kendoGrid({ dataSource: dataSource, sortable: true, selectable: true, rowTemplate: kendo.template($("#rowTemplate").html()), altRowTemplate: kendo.template($("#altRowTemplate").html()), columns: [ {field:"_id", title:"id"}, {field:"date", title:"date"}, {field:"activity", title:"activity"}, {field:"hours", title:"hours"} ], change: function(){ var selectedId = this.select().data("id"); selectedActivity = this.dataSource.get(selectedId); console.log("selected id:"+selectedId) console.log("selected activity is:"+JSON.stringify(selectedActivity)); }});When my change function is triggered, my selected id is undefined. My guess is that I have a misunderstanding somewhere in my data modelling or something of that nature.
Any hints would be appreciated, thank you very much!