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

Unable to group GRID by default field (Not drag¬

2 Answers 302 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Raul
Top achievements
Rank 1
Raul asked on 24 Jul 2017, 10:41 AM

Hi!
I obtain this error when I try to Grouping by a default field in my Grid.

"ArgumentException: Invalid property or field - 'description' for type: AggregateFunctionsGroup
Kendo.Mvc.Infrastructure.Implementation.Expressions.MemberAccessTokenExtensions.CreateMemberAccessExpression(IMemberAccessToken token, Expression instance)"

I've tried many combinations of options and none works.

        <div>
            @(Html.Kendo().Grid<Gap.Web.ViewModels.QuestionViewModel>(Model)
                                                .Name("Preguntas")
                                                .Columns(columns =>
                                                {
                                                    columns.Bound(p => p.Text).Width(200);
                                                    columns.Bound(p => p.description).Width(150);
                                                    columns.ForeignKey(p => p.DataTypeID, (System.Collections.IEnumerable)ViewData["DataTypeNameList"], "DataTypeID", "DataTypeName").Width(85);
                                                    columns.Bound(p => p.AnswerOptions).ClientTemplate("#=AnswerOptionTemplate(AnswerOptions)#").EditorTemplateName("AnswerOptionsEditor").Width(170);
                                                    columns.Bound(p => p.required).ClientTemplate(IsRequiredTemplate).HtmlAttributes(new { style = "text-align: center" }).Width(70);
                                                    columns.Command(command =>
                                                    {
                                                        command.Edit().Text("Editar")
                                                                      .UpdateText("Salvar")
                                                                      .CancelText("Cancelar");
                                                        command.Destroy().Text("Borrar");
                                                    }).Width(120);
                                                })
                                                .ToolBar(toolBar => toolBar.Create().Text("AƱadir"))
                                                .Selectable()
                                                .Editable(editable => editable.Mode(GridEditMode.InLine))
                                                .Scrollable(s => s.Virtual(true).Height("100%;"))
                                                .Groupable(false)
                                                .HtmlAttributes(new { style = "height:500px;" })
                                                .DataSource(datasource => datasource
                                                    .Ajax()
                                                    .ServerOperation(false)
                                                    .PageSize(40)
                                                    .Model(model =>
                                                    {
                                                        model.Id(p => p.Id);
                                                        model.Field(p => p.description).DefaultValue("");
                                                        model.Field(p => p.Text);
                                                        model.Field(p => p.DataTypeID).DefaultValue(0);
                                                        model.Field(p => p.AnswerOptions).DefaultValue(new List<Gap.Web.ViewModels.AnswerOptionViewModel>()); ;
                                                        model.Field(p => p.required).DefaultValue(true);
                                                    })                                                    

[THIS DOES NOT WORK] =>     .Group(g => g.Add("description", typeof(String)))
                                                    .Create(update => update.Action("EditingInline_Create", "Admin"))
                                                    .Read(read => read.Action("EditingInline_Read", "Admin"))
                                                    .Update(update => update.Action("EditingInline_Update", "Admin"))
                                                    .Destroy(update => update.Action("EditingInline_Destroy", "Admin"))
                                                    )
                                                    .Events(events => events
                                                        .Save("onSave")
                                                        .Cancel("onCancel")
                                                        .Edit("selectRowOnEdit")
                                                    )
                                                   .Deferred()
            )
        </div>

Any advice please?!

 

Thanks in advantage!

 

R.Perucha

2 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 27 Jul 2017, 05:45 AM
Hello Raul,

Thank you for the provided code.

After inspecting it, the implementation is following the recommendations and should work as expected.

I can assume that the issue may be caused by the way the data is processed in the controller.

Please check the following forum thread with a similar issue:

http://www.telerik.com/forums/filtering-when-using-a-viewmodel

If additional assistance is needed, please provide a fully runnable example and we will gladly assist.

Regards,
Stefan
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data (charts) and form elements.
0
Raul
Top achievements
Rank 1
answered on 27 Jul 2017, 08:20 AM

Hi Stefan,

Issue solved! The link you post helps me to understand how important is return to view the Model with .ToDataSourceResult()
Now it works perfectly, thanks a lot!

BR

Tags
Grid
Asked by
Raul
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Raul
Top achievements
Rank 1
Share this question
or