So how do I go about initializing the dropdowns (probably as disabled) on $(document).ready and then later populate them with data from the common DS?
This is what I did
- Created the DS global
var
weightDS =
new
kendo.data.DataSource();
- Kendo the inputs to create the dropdowns
$(
"#from-select"
).kendoDropDownList({
index: 0,
dataTextField:
"Msre_Desc"
,
dataValueField:
"Msre_Desc"
,
dataSource: weightDS
});
$(
"#to-select"
).kendoDropDownList({
index: 1,
dataTextField:
"Msre_Desc"
,
dataValueField:
"Msre_Desc"
,
dataSource: weightDS
});
In the callback I then assign the datasource url and read in the data
weightDS =
new
kendo.data.DataSource({
type:
"odata"
,
//Specifies data protocol
transport: {
read: currentItem.usda_WEIGHT.__deferred.uri
}
});
weightDS.read();
...but the dropdowns aren't populating with the data from the DS.
What am I missing or doing wrong? I thought once they were bound and the DS changes, all controls using that DS are re-bound?
13 Answers, 1 is accepted
Ok, so I need to store a 3rd value somewhere...
So the dropdownlist has Text and Value right?...those are bound to two seperate properies...butI need access to a THIRD piece of dataitem each listitem is bound to.
Is the full data item available by any chance somewhere for the selected item?
Or perhaps the way to do it is have the dropdown values be the PK, then search for that in the DS objects resultset somehow?
I believe that you will need to use "autoBind: false" in order to bind the dataSource later. Check this jsFiddle example.
Georgi Krustev
the Telerik team
Thanks for the sample!
Oh, so here's where I'm stuck...
This is the source of the DS:
var
item =
this
.dataSource.view()[
this
._current.index()];
//Get the weight navproperty
weightDS =
new
kendo.data.DataSource({
type:
"odata"
,
//Specifies data protocol
transport: {
read: item.usda_WEIGHT.__deferred.uri
}
});
So it happens in the Change event of a combobox...and so I need to get the selected dataitem index...and then the "read" is the navigation property...
So how would I set that initially on load if it isn't available yet?...I tried modifying your fiddle...but I have no idea what I'm doing to get the read to work :)
(my modified version)
http://jsfiddle.net/gNhTp/1/
So essentially the datasource is nothing until the click happens...that's where I'm stuck
Steve
If I understand you correctly, you need to define URL after the page is loaded. If my assumption is correct, then you will need to create DataSource with empty URL and then set it to the transport. Check the updated jsFiddle example.
Please note that you cannot change the DataSource of the components on the fly.
Georgi Krustev
the Telerik team
How do I stop the expand animation on those dropdowns?...when bound to multiples it's very distracting...AND\OR keep them both open so I could make two selections.
You can stop the expand animation overriding the popup open/close animation. Check this thread for more information.
When bind the DropDownList (ComboBox or AutoComplete too), the popup is opened. This is a known issue, which is already addressed and the fix will be included in the next official release of KendoUI.
Keeping both popups opened is not supported, because the popup is closed on mousedown of the document body.
Georgi Krustev
the Telerik team
http://screencast.com/t/eBVYqTw11a
Whenever I try and set the DS like that I get a "d.bind is not a function" error in the console...?
forgot the NEW when creating the DS object :)
You know what...I kind of LIKE the animation happening now when the DS changes...saving the users an extra click or two.
Could that functionality be toggleable if you've "fixed" the bug? :)
Steve
The opening of the popup on rebind is addressed and the fix will be included in the next official release of KendoUI.
You can achieve the required functionality with using open() method of the widget.
Georgi Krustev
the Telerik team