This is a migrated thread and some comments may be shown as answers.

Multiple dropdowns, same DS

13 Answers 652 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
sitefinitysteve asked on 16 Oct 2011, 09:10 PM
Ok, so my datasource is only available AFTER an $ajax request.

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

Sort by
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 16 Oct 2011, 11:12 PM
**Second Problem**

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?
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 19 Oct 2011, 04:31 AM
Can anyone help?  I don't want to demo this with unstyled inputs which POP into kendo objects when the callback happens.
0
Georgi Krustev
Telerik team
answered on 20 Oct 2011, 08:37 AM
Hello Steve,

 
I believe that you will need to use "autoBind: false" in order to bind the dataSource later. Check this jsFiddle example.

Best regards,
Georgi Krustev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 23 Oct 2011, 01:25 AM
Hey Georgi,
  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
0
Georgi Krustev
Telerik team
answered on 26 Oct 2011, 02:00 PM
Hello 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. 

Regards,
Georgi Krustev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 26 Oct 2011, 07:06 PM
I havent put it into the project yet, but looks like that's EXACTLY what I need, thanks :)
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 28 Oct 2011, 07:10 PM
@Georgi

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.
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 01 Nov 2011, 06:10 PM
Any news?...this doable?  I have a client breathing down my neck :)
0
Georgi Krustev
Telerik team
answered on 02 Nov 2011, 08:48 AM
Hello Steve,

 
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.

Regards,
Georgi Krustev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 04 Nov 2011, 05:32 AM
Ok so heres what happens when I try it using the same version as the fiddle

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...?
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 05 Nov 2011, 03:15 AM
**EDIT** 'twas a typo

forgot the NEW when creating the DS object :)
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 05 Nov 2011, 04:11 AM
@Georgi
  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
0
Georgi Krustev
Telerik team
answered on 08 Nov 2011, 11:50 AM
Hello 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.

All the best,
Georgi Krustev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
DropDownList
Asked by
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Answers by
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Georgi Krustev
Telerik team
Share this question
or