ComboBox not working when acquired through Ajax Actionlink

7 posts, 1 answers
  1. Yngve
    Yngve avatar
    19 posts
    Member since:
    Feb 2017

    Posted 09 Jun Link to this post

    Hi,

     

    I have an Ajax action link which GETs a partial view and insert it after a certain div on my page. That partial view contains a Kendo ComboBox which is bound to a SelectList in my model. But the ComboBox doesn't work at all when the partial has been inserted. None of the styling and functionality is there at all. In fact, all the kendo html is gone. There are no elements with the "k-combobox" and "k-widget" stuff. Everything is gone, and all I'm left with is

     

    <input data-val="true" data-val-number="Feltet Prosjekt må være et tall." id="Sections_8fcdf2f0-53c3-45e3-9498-41aeaccf3ad4__ProjectId" name="Sections[8fcdf2f0-53c3-45e3-9498-41aeaccf3ad4].ProjectId" type="text" value="1">
    <script>
        jQuery(function(){jQuery("#Sections_8fcdf2f0-53c3-45e3-9498-41aeaccf3ad4__ProjectId").kendoComboBox({"dataSource":[{"Text":"Testprosjekt","Value":"1"},{"Text":"asd","Value":"2"},{"Text":"Ttest","Value":"3"},{"Text":"asd","Value":"4"},{"Text":"Best Project Ever","Value":"5"},{"Text":"test2000","Value":"6"},{"Text":"asdiasd","Value":"7"},{"Text":"ghghj","Value":"8"},{"Text":"sdfsd","Value":"9"},{"Text":"rtrtfgh","Value":"10"}],"dataTextField":"Text","dataValueField":"Value","placeholder":"Velg prosjekt...","suggest":true});});
    </script>

     

     

     

     

     

     

  2. Yngve
    Yngve avatar
    19 posts
    Member since:
    Feb 2017

    Posted 09 Jun in reply to Yngve Link to this post

    Isn't it possible to edit my post?

    Anyways.. I ment to say an EditorTemplate. Not a partial.

  3. Joana
    Admin
    Joana avatar
    134 posts

    Posted 13 Jun Link to this post

    Hello Yngve,

     

     

    I am afraid the information you have provided is not sufficient to define the cause of the issue. Make sure that you have correctly fulfilled all steps explained here: 

     

    http://docs.telerik.com/aspnet-mvc/introduction#next-steps

     

    Other useful articles:

     

    http://docs.telerik.com/aspnet-mvc/helpers/combobox/overview#the-basics

     

    http://docs.telerik.com/aspnet-mvc/introduction#next-steps

     

    http://www.telerik.com/forums/how-to-add-combobox-to-editor-template-using-grid-pop-up

     

    You could send us a sample with the code in your project so that we could examine it on our side and provide a solution.

     

    Regards,
    Joana
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  4. Yngve
    Yngve avatar
    19 posts
    Member since:
    Feb 2017

    Posted 15 Jun Link to this post

    Here is a project I made with an example in Home/Index

     

    Dropbox link

  5. Answer
    Ianko
    Admin
    Ianko avatar
    1740 posts

    Posted 19 Jun Link to this post

    Hello Yngve,

    The described behavior happens because the AJAX call from the Ajax.ActionLink does not evaluate JavaScript. You can read more about that here: https://stackoverflow.com/questions/1840620/asp-net-mvc-run-javascript-in-partialview-when-loaded-using-ajax-actionlink. Thus, the JavaScript logic outputted from the wrapper is never run so to.

    I would suggest you implementing this by using jQuery.ajax method instead. As suggested in StackOverflow.

    Regards,
    Ianko
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  6. Yngve
    Yngve avatar
    19 posts
    Member since:
    Feb 2017

    Posted 21 Jun in reply to Ianko Link to this post

    Hi, thanks for the answer. I changed it so I'm using jQuery.ajax now, but there's still an issue. My page has the ability to load in a section with the ajax link. And it's the section that contains the combobox. When I try to load the first section everything is fine. But if I try to load another section, the same problem occurs.
  7. Yngve
    Yngve avatar
    19 posts
    Member since:
    Feb 2017

    Posted 21 Jun in reply to Yngve Link to this post

    Nevermind. Seemed to be an issue with using the name property, because they were all being named the same. Removed name and it works.
Back to Top