I am trying to populate a Kendo list box from a kendo grid selection. The way it should work is that when a user selects the row a column in the grid will display that item in the list box. The problem I am having is that I cannot access the object in the dataitem I want to use. the object is visible and the fields inside it are correct I just need to be able to send that object to a list box where it looks for the valuefield and textfield.
I have been searching for a solution for a few days now. I am wondering really what I should be searching for at this point. I cant figure out what it is that will allow me to pull this object out of the dataItem to use it in my list box.The dataItem is [object(anonymous function)],The object inside the dataItem is:RolesLists [object(init)]. It is the RolesLists that I need to retrieve and send to the List Box. Nothing works as dataItem.RolesLists stays undefined.
I get the grid data in the grid , and I get the list box to send the data to in the second line. I then get the dataItem from the grid which gives me everything selected. I remove anything currently in the list box.Finally I add the dataItem, which should be dataitem.RolesLists. That comes up as undefined.
var grid = $('#grid').data('kendoGrid');
var listboxSelected = $('#selected').data('kendoListBox');
var dataItem = this.dataItem(grid.select());
listboxSelected.remove(listboxSelected.items());
listboxSelected.add(dataItem);
Well I figured it out I was making an error , my apologies for wasting everyones time. The code above was correct and you can use it if you wish to retrieve an item from a Kendo grid and populate any element with it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.