PopupEdit Template Events + DropDownList Cascade and Filtering

4 posts, 0 answers
  1. Robert Madrian
    Robert Madrian avatar
    96 posts
    Member since:
    Apr 2003

    Posted 14 Jun Link to this post

    Hello,

    I use a PopupEdit Template with cascading DropDownLists and in th second DropDownList a serverfilter (see code)

    the problem is, that the template is loaded on grid load and the second DropDownList does'nt work because the value of the
    field $("#Fachgruppe_Version_ID").val() in the template is not set at this time...

    • how to solve this problem?
    • I know that there is a onEdit event from the grid but how to call scripts in the template?
    • what's the best way to use Javascript/JQuery in the template (View Components, partial views)?

    robert

    @(Html.Kendo().DropDownListFor(model => model.Fachgruppe_ID)
                                     .DataTextField("Fachgruppe")
                                     .DataValueField("Fachgruppe_ID")
                                     .BindTo((IEnumerable) ViewData["Fachgruppe"])
                                     .HtmlAttributes(new {style = "width:500px"})
                                     .CascadeFrom("Sparte_ID")
                                     )
     
                               @(Html.Kendo().DropDownList()
                                     .Name("FG")
                                     .HtmlAttributes(new {style = "width:100%"})
                                     .OptionLabel("Select product...")
                                     .DataTextField("Fachgruppe")
                                     .DataValueField("Fachgruppe_ID")
                                     .DataSource(source =>
                                     {
                                         source.Read(read =>
                                         {
                                             read.Action("FachgruppeVersion_Read", "Home")
                                                 .Data("filterFachgruppe");
                                         })
                                             .ServerFiltering(true);
                                     })
                                     .Enable(true)
                                     .AutoBind(false)
                                     .CascadeFrom("Sparte_ID")
                                     )
     
                               <script>
                                   function filterFachgruppe() {
                                       return {                            
                                           version_id: $("#Fachgruppe_Version_ID").val()
                                       };
                                   }
                               </script>

  2. Danail Vasilev
    Admin
    Danail Vasilev avatar
    1494 posts

    Posted 16 Jun Link to this post

    Hi Robert,

    You should place the JavaScript code in the main view (e.g., where resides the grid). You can also find a fully runnable sample on this scenario here - grid-editing-cascading-dropdownlist

    Regards,
    Danail Vasilev
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Robert Madrian
    Robert Madrian avatar
    96 posts
    Member since:
    Apr 2003

    Posted 16 Jun in reply to Danail Vasilev Link to this post

    might be another approach to place the Javascript code on the partial view and call the Javascript functions from the main view onEdit event?
  5. Danail Vasilev
    Admin
    Danail Vasilev avatar
    1494 posts

    Posted 20 Jun Link to this post

    Hi Robert,

    Your questions is not directly related to Kendo UI components but a general ASP.NET MVC knowledge. Nevertheless, you can find more information on the matter on the Internet, for example the following forum threads:
         - http://stackoverflow.com/questions/27410367/mvc-partial-view-javascript
         - http://stackoverflow.com/questions/30478252/call-javascript-from-within-an-asp-net-mvc-partial-view
         - http://stackoverflow.com/questions/11098198/is-it-ok-to-put-javascript-in-partial-views

    Regards,
    Danail Vasilev
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
UI for ASP.NET MVC is VS 2017 Ready