I'll keep the question below, but if anybody else has this problem the issue was a bug in kendo and has been fixed in the most recent version. So the solution is to update to the latest kendo release.
I've been trying to find a good way of listing all of the nodes in a kendo-ui treeview, and have managed to put together a pretty solid way of doing so. First I define the dataSource, for the sake of simplicity let's say:
data = [
{text:element1, items:[
{text:element2},
{text:element3}]},
{text:element4}]
Then, I set the data source as an observableHierarchy:
my_treeview.setDataSource(kendo.observableHierarchy(data));
When I want to access the list of nodes, I can get a JSON object with:
my_treeview.dataSource.data().toJSON();
This works well; it produces a correct, properly-formatted JSON object. If I call JSON.stringify on the above, I get:
[{"text":"element1","items":[{"text":"element2","items":[]},{"text":"element3","items":[]}]},{"text":"element4","items":[]}]
However, when I enable drag and drop on my tree and drag an element into a different parent, it disappears from the json output. For example, if I drag element3 into element4, the json object returned is:
[{"text":"element1","items":[{"text":"element2","items":[]}]},{"text":"element4","items":[]}]
Which is the equivalent of:
data = [
{text:element1, items:[
{text:element2}]}
{text:element4}]
The table's display remains correct, however, with element 3 appearing to be a child of element4. So my question is, how can I get the dataSource to update properly with drag & drop?
If anybody else has this problem, the issue was a bug in kendo which has been fixed in the most recent version. So the solution is to update to the latest kendo release.
Related
I've got an array that, on its own, produces a grid no problem. I want to add one more row by pushing or adding to the datasource beforehand. Console.log after push shows the new array to be valid, but nothing appears on the Grid. Using add rather than push causes ONLY the new item to be display, while console.log shows all the items. Any ideas what gives?
EDIT: More strangely, I can loop through entries of a given array, extract some text and push that to a new array using ({'text':item[i].text}), but then outside of the loop pushing ({'text':'other text'}) doesn't show up as a row. Ugh.
EDIT #2: I've fixed the issue with the push to new array. Still not clear on certain kendoGrid functionality though, almost seems worth ignoring it altogether and just using kendoListView and utilising templates.
I'm trying to use a kendo.data.ObservableArray as data for data source of the grid. It shows ok. When edit inline, change a field, then cancel, the values are changed. When clicking edit, then click edit on another row, the last one remains in the edit mode. Sometimes cancel not work. On the array it works as expected.
I took the Kendo UI Demo, http://demos.telerik.com/kendo-ui/grid/editing-inline, to reproduce the issue. Here is the issue: http://dojo.telerik.com/uLiCi/2
Does anyone have any idea why so strange behavior?
In my opinion, it should work with both, array and observable array.
Thanks in advance
I am working on developing a cascading drop down with Kendo MVVM. The issue is that when the drop down loads the child drop down initially displays "undefined". This disappears though when I select some data in the parent drop down.
Alternatively I also require a Reset button in place. On click of this button I need to reset the cascade so that we get back to the initial phase(i.e. the child drop down should be disabled and no data should be selected in the parent).
Please find a JSBin that I created for the issue here
Thanks in advance for the help.
You should be using IDs as values, not strings. I think you can play around with data-primitive-value but why? Just use proper structure to begin with. For the clear, just dropdownlist.select(0) or dropdownlist.select("") if you managed to make it work with the primitive value thing.
http://dojo.telerik.com/ePIDO
've just tried giving the latest release of Kendo UI a spin, but it seems something has broken when using a DropDownList in a custom popup editor.
If the dataSource of the DropDownList is set to a JavaScript array or object, the selected value does not update the Grid model.
DropDownLists that have a remote dataSource with dataTextField and dataValueField configured are working okay.
Basically, code that worked perfectly with the 2014.3.1316 release is not working with the 2015.1.318 release (no errors are reported in Chrome's console).
Can somebody please confirm that this is a bug with the new release, or is there something else I need to be aware of?
EDIT: This is seems to be affecting all DropDownLists. The selected item is not updating the model immediately -- only when the record is saved.
I've knocked together a simple Fiddle to demonstrate the issue. With the previous version, selecting an item updates the Grid's model immediately and set's dirty to true. With the new version, the Grid's model isn't updated (at least not immediately).
The described issue is a known bug in Q1 2015 - BUG 623.
It is addressed in the latest internal builds and the upcoming service pack, that will be released till the end of week, will include the fix (and many more)
I am afraid that there is no simple workaround, as the widget just sets its "_old" value to the new one on first select. Hence the change event will not be raised. The only feasible solution is to upgrade to a newer version of Kendo UI.
When it comes to the dropdownlist and multiselect controls they have changed a lot to allow the new grouping and virtualization features to work. (having been a victim of this change as well - I'm still trying to fix my code at the minute)
I have updated your fiddle with a possible solution for what you want to achieve Update with Change Event added
I have basically added this function for you:
function changeCategory(e)
{
$('#log2').text('This should be the ID of the category you changed too: '+
e.sender.value());
}
but for more information on this change you can look here:
Changes to Kendo UI Q1 2015
EDIT:
Also if my memory is correct I think the select event is fired before the change event so that will always show the previous value and not the new value that has been selected and when you click update the grid is updating as expected from what I can see.
just try to specify a defaultValue in your schema model definition to CategoryID, i think this would be a better solution, couse this bug occurs only when the value is empty
The Changes to Kendo UI Q1 2015 page doesn't directly mention the change in behavior described, but it's likely to be caused by the substantial changes to the DropDownList widget.
There's a pretty simple workaround, but I suspect it shouldn't be necessary and will be 'fixed' at some point.
To emulate the old behavior you just need to manually set the model field that's supposed to be updated immediately. So in the select event add something like...
model.set('CategoryID', dataItem.CategoryID);
Updated Fiddle. Without doing this, any dependent methods will use the original or old value, which is simply not right (hence, I suspect it'll be fixed).
I also experienced the problem with dropdown lists with the 2015.1.318 release.
In the latest release, 2015.1.327, this seems to be fixed.
I have a grid that is populated by a JSON response (MVC3 controller) that has a userData component for some additional data for grid captions, etc. All that works just fine. I recently switched the the grid's data loading to "loadonce: true" as in working with larger grid results sets, I wanted client-side sorting and filtering. All that works good. BUT, I was surprised that the userData got wiped the first time I clicked any column for sorting. If I turn off loadonce, userData is fine, but it is of course going back to the server each time. The items that make use of the userData fire on gridcomplete and are now coming back "undefined" after a sort (and probably anything that reloads the grid). Any thoughts why this might be happening? Oh yeah, I also noticed that clicking a column sort wiped out any multiselections (perhaps related to the same culprit?).
Thanks,
Mark
You are right. +1 from me. It's a jqGrid bug. Inside of internal addLocalData method after the line 1527 of the file grid.base.js of jqGrid 4.1.2 or after the 1532 of jquery.jqGrid.src.js (you can get modified version from here) one should add the following line
retresult[ts.p.localReader.userdata] = ts.p.userData;
It will fix the problem. I posted the corresponding bug report here.