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

PopupEdit Template Events + DropDownList Cascade and Filtering

3 Answers 84 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Robert Madrian
Top achievements
Rank 1
Veteran
Iron
Robert Madrian asked on 14 Jun 2016, 01:10 PM

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>

3 Answers, 1 is accepted

Sort by
0
Danail Vasilev
Telerik team
answered on 16 Jun 2016, 07:28 AM
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
0
Robert Madrian
Top achievements
Rank 1
Veteran
Iron
answered on 16 Jun 2016, 08:01 AM
might be another approach to place the Javascript code on the partial view and call the Javascript functions from the main view onEdit event?
0
Danail Vasilev
Telerik team
answered on 20 Jun 2016, 07:24 AM
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
Tags
Grid
Asked by
Robert Madrian
Top achievements
Rank 1
Veteran
Iron
Answers by
Danail Vasilev
Telerik team
Robert Madrian
Top achievements
Rank 1
Veteran
Iron
Share this question
or