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

entire model showing in popup

3 Answers 189 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 10 Feb 2019, 02:01 PM

Hi I am using the grid in asp.net core 2.1 excellent product by the way however i am having an issue its the inline popup is display more fields than i have defined in my grid layout for example

In my grid I would be expecting just the five columns here but its displaying the entire model in the popup. Also how does one use dapper for the crud operations is that possible as I am using stored procs to keep my site fast and clean to acehieve this.

 

Also how do i color the command buttons is that simple enough?

 

columns.Bound(p => p.Name).Filterable(false);
                        columns.Bound(p => p.Description);
                        columns.Bound(p => p.ActivityDate).Format("{0:MM/dd/yyyy}");
                        columns.Bound(p => p.EmployeeName);
                        columns.Bound(p => p.Status);

@(Html.Kendo().Grid<FuelActivityTrackerDal.Models.ActivityHeader>()
                    .Name("grid")
                    .Columns(columns =>
                    {
                        columns.Bound(p => p.Name).Filterable(false);
                        columns.Bound(p => p.Description);
                        columns.Bound(p => p.ActivityDate).Format("{0:MM/dd/yyyy}");
                        columns.Bound(p => p.EmployeeName);
                        columns.Bound(p => p.Status);
                        columns.Command(command => { command.Edit(); command.Destroy(); }).Width(160);
 
                    })
                       .ToolBar(toolbar => toolbar.Create())
    .Editable(editable => editable.Mode(GridEditMode.PopUp))
                    .Pageable()
                    .Sortable()
                    .Scrollable()
                    .Filterable()
                    .HtmlAttributes(new { style = "height:550px;" })
                    .DataSource(dataSource => dataSource
                        .Ajax()
                        .PageSize(Model.Count())
                        .Read(read => read.Action("Activity_Read", "Activity"))
                    )
)
 
 
<script type="text/javascript">
    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);
        }
    }
</script>

3 Answers, 1 is accepted

Sort by
0
Tsvetomir
Telerik team
answered on 14 Feb 2019, 06:20 AM
Hi David,

By default, the popup editing functionality of the grid is configured to render an Html.EditorForModel method. That is why the whole model is loaded in the editor. More information on the matter could be found in the following article:

https://docs.telerik.com/aspnet-mvc/helpers/grid/templating/editor-templates#overview

What you can do is declare a custom popup editor. We have created a sample which demonstrates how to create a custom editor. It can be found in our GitHub repository:

https://github.com/telerik/ui-for-aspnet-mvc-examples/tree/master/grid/custom-popup-editor

The file of interest is Person.cshtml and is located in the following folder:


Views/Shared/EditorTemplates/Person.cshtml


Alternatively, if the whole model is not being used, I would recommend creating a new view model. This would reduce the size of the requests because even though the grid does not display all of the fields, the server will send them in the response.


Kind regards,
Tsvetomir
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
David
Top achievements
Rank 1
answered on 16 Feb 2019, 07:40 PM
I dont really want my code in a popup is their a way to redirect to another view like say edit?.
0
Tsvetomir
Telerik team
answered on 21 Feb 2019, 06:32 AM
Hi David,

The Kendo UI Grid provides the editing functionality out-of-the-box. Moreover, you can configure the templates according to your preferences.

Redirecting another view is a doable approach. You can have a link column, which redirects to the specific view. That edit view will show the relevant editors for the Model. The approach will be very similar to the one illustrated in the Microsoft articles below:



Kind regards,
Tsvetomir
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
David
Top achievements
Rank 1
Answers by
Tsvetomir
Telerik team
David
Top achievements
Rank 1
Share this question
or