Farahatology
Farahatology

Reputation: 133

Sorting By Foreign key Column Text not value in Kendo Grid MVC

the sorting in mvc kendo grid foreign column sort by values not text enter image description here

the code is

@Html.Kendo().Grid( _
    Of cls.ProductSpecificationM).Name("Grid").Columns(
    Sub(i)
            i.Bound(Function(p) p.ProductSpecification_ID).Hidden(True)

            i.ForeignKey(Function(p) p.Attribute_ID_FK, DirectCast(ViewBag.Attributes, System.Collections.IEnumerable), "Attribute_ID", "Attribute_Name").EditorTemplateName("_Attribute_ID_FK").Title("Name")
            i.ForeignKey(Function(p) p.AttributeValue_ID_FK, DirectCast(ViewBag.AttributeValues, System.Collections.IEnumerable), "AttributeValue_ID", "AttributeValue_Name").EditorTemplateName("_AttributeValue_ID_FK").Title("Value")
            i.Command(Sub(w)
                              w.Destroy()
                      End Sub)
    End Sub).ToolBar(Sub(k)
                             k.Create() : k.Save()

                     End Sub).Editable(Function(e) e.Mode(GridEditMode.InCell)).Pageable(Function(i) i.Input(True).PageSizes({10, 20, 50, 100, 200, 300, 400}).Refresh(True)).Sortable().Filterable().DataSource( _
                                                       Function(p) p.Ajax().PageSize(50).Batch(True).ServerOperation(False).Model(Sub(i)
                                                                                                                                          i.Id(Function(p2) p2.ProductSpecification_ID)
                                                                                                                                          i.Field(Function(p2) p2.Item_ID_Fk).DefaultValue(ViewBag.Id)
                                                                                                                                          i.Field(Function(p2) p2.AttributeValue_ID_FK).DefaultValue(1)
                                                                                                                                          i.Field(Function(p2) p2.Attribute_ID_FK).DefaultValue(1)
                                                                                                                                  End Sub) _
                                                             .Read("EditingInline_Read", "Products", New With {.id = ViewBag.Id}) _
                                                             .Update(Function(u) u.Action("EditingInline_Update", "Products")) _
                                                             .Destroy(Function(update) update.Action("EditingInline_Destroy", "Products")) _
                                                             .Create(Function(update) update.Action("EditingInline_Create", "Products"))).Events(Function(e) e.Edit("edit"))

how Can I sort by the column text ?

Upvotes: 3

Views: 2871

Answers (1)

HaBo
HaBo

Reputation: 14287

Looks like kendo doesn't support it. Need to come up with some other solution.

Reponse by Atanas Korchev (Admin, Kendo UI) We can’t support this in all cases because the data source won’t have all data (it usually has just the foreign key which is the value)

You can use Grouping if that helps to some extend. Grouping column in Kendo

Upvotes: 2

Related Questions