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

Script Hierarchy

1 Answer 11 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Joel
Top achievements
Rank 1
Veteran
Iron
Iron
Joel asked on 03 Apr 2019, 04:39 PM
If I have a script inside a Partial, help me understand how I can call a script on the Host/Parent View.  So, from a Grid Command, how do I call a function locally to capture a value then feed that value to the Host/Parent View?

1 Answer, 1 is accepted

Sort by
0
Accepted
Alex Hajigeorgieva
Telerik team
answered on 08 Apr 2019, 03:04 PM
Hi, Joel,

A function declared in the partial view will have access to any widgets which are in the main view. Since I do not understand the entirety of the scenario, I will give you an example. 

- I have a Kendo UI TreeList in my Index.cshtml view which also renders a grid partial:

@(Html.Partial("_GridPartial"))

- In the partial file, the grid has a command column with a click event handler that gets the currently clicked row and highlights a row from the TreeList which is on the main page:

columns.Command(command => command.Custom("custom").Click("customCommandClick").Text("Custom Command").IconClass("k-icon k-i-eye"));
 
<script>
    function customCommandClick(e) {
        e.preventDefault();
        var tr = $(e.target).closest("tr");
        var dataItem = this.dataItem(tr);
        var treelist = $("#treelist").data("kendoTreeList");
        treelist.select($("tr:eq(" + dataItem.OrderID + ")"));
    }
</script>

In case you have something else in mind, please elaborate on the specifics of the scenario so I may alter my suggestion accordingly.

Kind Regards,
Alex Hajigeorgieva
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Grid
Asked by
Joel
Top achievements
Rank 1
Veteran
Iron
Iron
Answers by
Alex Hajigeorgieva
Telerik team
Share this question
or