This is a migrated thread and some comments may be shown as answers.
Results not being displayed in cascading MultiSelectComboBox in Grid
2 Answers 14 Views
This is a migrated thread and some comments may be shown as answers.
Rob
Top achievements
Rank 1
Rob asked on 24 Mar 2019, 12:38 AM

I have a grid:

@(Html.Kendo().Grid(Model.Lines)
    .Name("lines")
    .Columns(columns =>
    {
        columns.Bound(p => p.Item).ClientTemplate("#= (Item.Name) ? Item.Name : '' #");
        columns.Command(command => command.Destroy());
    })
    .ToolBar(tools =>
    {
        tools.Excel();
        tools.Pdf();
        tools.Save().HtmlAttributes(new { style = "float:right" });
        tools.Create().HtmlAttributes(new { style = "float:right" });
    })
    .AllowCopy(true)
    .Excel(excel => excel.FileName("LinesExport.xlsx"))
    .Editable(editable => editable.Mode(GridEditMode.InCell))
    .Navigatable()
    .Sortable()
    .Filterable()
    .DataSource(dataSource => dataSource
        .Ajax()
        .Model(model =>
        {
            model.Id(i => i.Id);
            model.Field(i => i.Id).Editable(false);
            model.Field(i => i.ItemId).Editable(false);
            model.Field(i => i.Item).Editable(true).DefaultValue(new Item { ItemId = "", ItemGroup = "", Name = "", SearchName = "" });
        })
        .Batch(true)
        .ServerOperation(false)
    )
)

 

with a custom editor on a field:

@model Item
 
@(Html.Kendo().MultiColumnComboBoxFor(m => m)
    .Placeholder("Select item")
    .DataTextField("Name")
    .DataValueField("ItemId")
    .Columns(columns =>
    {
        columns.Add().Field("ItemId").Title("Item Number").Width("180px");
        columns.Add().Field("Name").Title("Name").Width("180px");
        columns.Add().Field("SearchName").Title("Search Name").Width("180px");
        columns.Add().Field("ItemGroup").Title("Item Group").Width("180px");
    })
    .Filter(FilterType.Contains)
    .FooterTemplate("Total #: instance.dataSource.total() # items found")
    .Height(400)
    //.Events(events => events.Change("onComboBoxChange"))
    .DataSource(source => source
        .Read(read =>
        {
            read.Action("GetItems", "Home").Data("getItemsData");
        })
        .ServerFiltering(false)
    )
    .CascadeFrom("CustomerId")
)

 

The custom editor displays correctly for the Item field.  When Customer changes (happens elsewhere) it is cascading properly and the read action is getting called.  The read action is returning results (can see this by inspecting the result in the RequestEnd event) but no results are actually displayed in the MultiColumnComboBox.  I have another MultiColumnComboBox elsewhere on the page that is not in the grid that cascades from the same value and does an almost identical lookup and it works fine.

 

What am I missing here?  or is this a bug and if so how do I work around it?

 

 

 

2 Answers, 1 is accepted

Sort by
0
Rob
Top achievements
Rank 1
answered on 25 Mar 2019, 10:46 PM
So I eventually worked out what the problem was here: the objects returned by the GetItems method did not have a CustomerId column on them.  However this is odd as I have other columns in the grid that cascade from ItemId and they work but the objects returned from their call do not contain an ItemId.  The only difference that I can see between the 2 cases is that in the Customer/Item case, Customer is on a different object to Item where as in the Item/OtherThing case they are on the same object.
0
Konstantin Dikov
Telerik team
answered on 27 Mar 2019, 03:14 PM
Hi Rob,

It is possible that the Read action for the MultiColumnComboBox was expecting a CustomerId value in order to return the correct data. Nevertheless, without the code of the action method it would be really difficult to guess what was the exact problem.


Regards,
Konstantin Dikov
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.
Asked by
Rob
Top achievements
Rank 1
Answers by
Rob
Top achievements
Rank 1
Konstantin Dikov
Telerik team
Share this question
or