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

is "parent" a reserved word in Grid?

1 Answer 110 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Wyatt
Top achievements
Rank 1
Wyatt asked on 10 Jun 2016, 07:15 PM

I have a very basic grid that I built with the telerik mvc grid scaffolding.

 

I have a column called "parent"  that parent should display a 10 digit number, instead it displays "function (){return o}"

 

I have tried templating, toString and it shows the same thing.  every other column works as expected

 

 

@(Html.Kendo().Grid<AccountMove.act_trans_worktable>()
      .Name("grid")
      .Columns(columns =>
      {
          columns.Bound(c => c.customer_name);
          columns.Bound(c => c.reason);
          columns.Bound(c => c.parent);
      })
      .Pageable()
      .Navigatable()
      .Sortable(sortable =>
      {
          sortable.SortMode(GridSortMode.SingleColumn);
      })
      .Filterable()
      //.Scrollable()
      .DataSource(dataSource => dataSource
          .Ajax()
          .Read(read => read.Action("act_trans_worktable_Read", "mvcgrid"))
      )
)

1 Answer, 1 is accepted

Sort by
0
Marin
Telerik team
answered on 13 Jun 2016, 05:14 PM
Hello,

Yes, the "parent" keyword is used internally by the observable kendo model of the grid. That's why it is not recommended to have a "parent" field in the model's data.
Using a kendo widget allows you to define an alias for this field and use this instead, which can resolve the problem:
$("#grid").kendoGrid({
    dataSource: {
        data: products,
            schema: {
                model: {
                    fields: {
                        foo: {type: "string", from: "parent"},
                            ProductName: { type: "string"
                                    }
                                }
                            }
                        },
                        columns: [
                            { field: "foo", title: "parent"},
                            "ProductName"
                        ]
                    });

The MVC wrapper however does not provide such option at moment. So the best option there would be to change the column name. For example: "Parent" with capital "P" will work as expected.

Regards,
Marin
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
Wyatt
Top achievements
Rank 1
Answers by
Marin
Telerik team
Share this question
or