Add items afer databind

8 posts, 0 answers
  1. Steve
    Steve avatar
    1851 posts
    Member since:
    Dec 2008

    Posted 11 Dec 2011 Link to this post

    After my DS rebinds the combo boxes I need to add a couple items at index 0 on the combos.

    ...so now I'm pretty sure I could just jQuery them in there...is that the proper way??

    **EDIT** I'm sorry, this should be in the DropDownList area!...same question though :)

    Steve
  2. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3706 posts

    Posted 13 Dec 2011 Link to this post

    Hello Steve,

     
    You can use the data() method of the DateSource. You should modify current list of items and pass it to the data() method.

    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!
  3. Kendo UI is VS 2017 Ready
  4. Steve
    Steve avatar
    1851 posts
    Member since:
    Dec 2008

    Posted 17 Dec 2011 Link to this post

    Could you give me a hand Georgi?

    I tried adding the item into the change event of the DS, but it (clearly) ends up in an infinite change loop :) Which means I can't modify the data of the DS directly right?

    So are you then saying I need to NOT bind my dropdowns to a DS and instead manually add the data in?
  5. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3706 posts

    Posted 20 Dec 2011 Link to this post

    Hello Steve,

     
    Yes, your observations are correct. The data cannot be modified in the change event of the DataSource. Actually the data() method triggers the change event. You should manually add the data. I created a simple jsFiddle demo, which shows what I mean.

    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!
  6. Cory Deppen
    Cory Deppen avatar
    11 posts
    Member since:
    Dec 2009

    Posted 29 Aug 2012 Link to this post

    So if you can't add an item in the change event of the dataSource, what is the best way to append/ prepend an item to a ComboBox after the data has been retrieved? It looks like there's an undocumented dataBound event, but that seems to yield the same result as the change event.
  7. Nicklas
    Nicklas avatar
    3 posts
    Member since:
    Jul 2013

    Posted 24 Aug 2013 Link to this post

    I have the same issue...
    tried dataBound event but hangs/loops as you say.
    How can i add an item manually after loading from db/json?
  8. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3706 posts

    Posted 29 Aug 2013 Link to this post

    Hello Nicklas,

     
    When add item to the DataSource, "change" event is raised and thus the widget falls into infinitive loop. You can handle this with a privite variable. Check the updated jsFiddle demo.

    Regards,
    Georgi Krustev
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  9. Nicklas
    Nicklas avatar
    3 posts
    Member since:
    Jul 2013

    Posted 08 Sep 2013 Link to this post

    Thank you Georgi!
    Your code works like a charm. Perfect!

    Sincerely
    Nicklas
Back to Top
Kendo UI is VS 2017 Ready