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

Grid inside window with content-url .Net Core

2 Answers 241 Views
Window
This is a migrated thread and some comments may be shown as answers.
Alberto Zanetti
Top achievements
Rank 1
Alberto Zanetti asked on 30 Jan 2019, 11:07 AM

Hello,

i'm trying to insert a view that includes a grid into a window but i get this error: GridAusiliOspite_Read_Parameters is not defined (but i've defined it in the View)

there is my code... 

Thanks in advance

View to render inside window:

<div class="col-sm-10 col-sm-offset-1">
        @(Html.Kendo().Grid<AusiliKendoGrid>().Name("GridAusili")
                        .Columns(columns =>
                        {
                            columns.Bound(p => p.Nome).ClientTemplate("#=Nome.Descrizione#");
                            columns.Bound(p => p.DataInizio);
                            columns.Bound(p => p.DataFine);
                            columns.Bound(p => p.Owner);
                            columns.Bound(p => p.GGpulizia);
                            columns.Command(command => command.Destroy());
                        })
                        .ToolBar(toolbar =>
                        {
                            toolbar.Create();
                            toolbar.Save();
                        })
                        .Pageable()
                        .Navigatable()
                        .Sortable()
                        .Editable(editable => editable.Mode(GridEditMode.InCell))
                        .DataSource(dataSource => dataSource
                            .Ajax()
                            .Batch(true)
                            .PageSize(20)
                            .ServerOperation(true)
                            .Events(events => events.Error("error_handler"))
                            .Model(model => {
                                model.Id(p => p.Id);
                                //model.Field(p => p.Nome);
                                model.Field(p => p.Nome).DefaultValue(ViewData["DefaultAusilio"] as SGL.Models.EditorTemplatesModel.NomeAusiliModel);
                            })
                        .Create(create => create.Action("GridAusiliOspite_Create", "SchedaInserimento").Data("GridAusiliOspite_Create_Parameters"))
                        .Read(read => read.Action("GridAusiliOspite_Read", "SchedaInserimento").Data("GridAusiliOspite_Read_Parameters"))
                        .Update("GridAusiliOspite_Update", "SchedaInserimento")
                        .Destroy("GridAusiliOspite_Destroy", "SchedaInserimento")
                        )
        )
    </div>
 
 
<script>
function error_handler(e) {
            if (e.errors) {
                var message = "Errors:\n";
                $.each(e.errors, function (key, value) {
                    if ('errors' in value) {
                        $.each(value.errors, function () {
                            message += this + "\n";
                        });
                    }
                });
                alert(message);
            }
        }
 
function GridAusiliOspite_Create_Parameters() {
            return {
                id_ospite: '@ViewData["idOspite"]'
            };
        }
 
 function GridAusiliOspite_Read_Parameters() {
            return {
                id_ospite: '@ViewData["idOspite"]'
            };
        }
    </script>

View where the window should appear:

<kendo-window name="window"
                                  title="Ausili"
                                  draggable="true"
                                  resizable="true"
                                  width="600"
                                  on-close="onClose"
                                  content-url="@Url.Action("Ausili", "SchedaInserimento")"
                                  actions="actions">
                         
                        <popup-animation enabled="false" />
                    </kendo-window>
                    <button type="button" class="col-sm-2 btn-sm btn-light" onclick="addAusili()">Ausili <i class="fab fa-accessible-icon"></i></button>

 

function addAusili() {
 
            $("#window").data("kendoWindow").open();
 
        }

2 Answers, 1 is accepted

Sort by
0
Accepted
Veselin Tsvetanov
Telerik team
answered on 31 Jan 2019, 10:46 AM
Hello Alberto,

When you load the Window content from an external view, the markup of the content will be evaluated line-by-line. Therefore, at the moment of the initialization of the Grid, the <script> tag containing the GridAusiliOspite_Read_Parameters function will not be evaluated yet. Therefore, I would suggest you to move the <script> tag before the Grid HTML helper definition.

Regards,
Veselin Tsvetanov
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.
0
Alberto Zanetti
Top achievements
Rank 1
answered on 31 Jan 2019, 11:02 AM
It works like a charm! Thank you!
Tags
Window
Asked by
Alberto Zanetti
Top achievements
Rank 1
Answers by
Veselin Tsvetanov
Telerik team
Alberto Zanetti
Top achievements
Rank 1
Share this question
or