Multiple dropdowns, same DS

14 posts, 0 answers
  1. Steve
    Steve avatar
    1885 posts
    Member since:
    Dec 2008

    Posted 16 Oct 2011 Link to this post

    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?
  2. Steve
    Steve avatar
    1885 posts
    Member since:
    Dec 2008

    Posted 16 Oct 2011 Link to this post

    **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?
  3. Steve
    Steve avatar
    1885 posts
    Member since:
    Dec 2008

    Posted 18 Oct 2011 Link to this post

    Can anyone help?  I don't want to demo this with unstyled inputs which POP into kendo objects when the callback happens.
  4. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3747 posts

    Posted 20 Oct 2011 Link to this post

    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!
  5. Steve
    Steve avatar
    1885 posts
    Member since:
    Dec 2008

    Posted 22 Oct 2011 Link to this post

    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
  6. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3747 posts

    Posted 26 Oct 2011 Link to this post

    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!
  7. Steve
    Steve avatar
    1885 posts
    Member since:
    Dec 2008

    Posted 26 Oct 2011 Link to this post

    I havent put it into the project yet, but looks like that's EXACTLY what I need, thanks :)
  8. Steve
    Steve avatar
    1885 posts
    Member since:
    Dec 2008

    Posted 28 Oct 2011 Link to this post

    @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.
  9. Steve
    Steve avatar
    1885 posts
    Member since:
    Dec 2008

    Posted 01 Nov 2011 Link to this post

    Any news?...this doable?  I have a client breathing down my neck :)
  10. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3747 posts

    Posted 02 Nov 2011 Link to this post

    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!
  11. Steve
    Steve avatar
    1885 posts
    Member since:
    Dec 2008

    Posted 04 Nov 2011 Link to this post

    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...?
  12. Steve
    Steve avatar
    1885 posts
    Member since:
    Dec 2008

    Posted 04 Nov 2011 Link to this post

    **EDIT** 'twas a typo

    forgot the NEW when creating the DS object :)
  13. Steve
    Steve avatar
    1885 posts
    Member since:
    Dec 2008

    Posted 04 Nov 2011 Link to this post

    @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
  14. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3747 posts

    Posted 08 Nov 2011 Link to this post

    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!
Back to Top