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

[Solved] Problem with embeded combobox into grid's cell. Disappear the selected value

0 Answers 20 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
xabikos
Top achievements
Rank 1
xabikos asked on 29 Nov 2011, 02:38 PM
Hello.

I am trying to use the combobox component into one grid's column to let user select a specific reference entity. What I have done until now based on this example which is exactly what i want to do except the javascript section to bind the selected value.
The code that creates the Grid is

@(Html.Telerik().Grid<Abe.Common.Procurements.ProcurementOrderLine>()
    .Name("procurementOrderLines")
    .DataKeys(keys => keys.Add(line => line.ID))
    .ToolBar(commands => {
        commands.Insert();
    })
    .DataBinding(databinding => {
        databinding.Ajax()
                .Select("_SelectBatchEditing", "ProcurementOrders", new {orderID = Model != null ? Model.ID : 0})
                .Update("_SaveBatchEditing", "ProcurementOrders");
    })
    .Columns(collumns => {
        collumns.Bound(l => l.ID).Hidden();
        collumns.Bound(l => l.Commodity).ClientTemplate("<#= Commodity ? Commodity.Code : null #>").Width(75);
        collumns.Bound(l => l.QuantityTemp).Width(40);
        collumns.Command(commands => commands.Delete()).Width(150).Title("Delete");
    })
    .ClientEvents(events => events.OnSubmitChanges("Grid_onSubmitChanges"))
    .Editable(editing => editing.Mode(GridEditMode.InCell)
            .DefaultDataItem(new Abe.Common.Procurements.ProcurementOrderLine {
                        Commodity = new Abe.Common.Transactions.CommodityInfo(),
                        Warehouse = new Abe.Common.Transactions.WarehouseInfo()
               }))
    .Scrollable()
    .Sortable()
)

I have created the additional editor for the Commodity reference as below

@model Abe.Common.Transactions.CommodityInfo
 
@(Html.Telerik().ComboBoxFor(model => model.ID)
    .AutoFill(true)
    .BindTo(new SelectList(ViewBag.Commodities, "ID", "Code"))
    .Filterable(filtering => filtering.FilterMode(AutoCompleteFilterMode.StartsWith))
    .HighlightFirstMatch(true))

and the binding works fine. The problem is that the combobox appears in the cell only when i click into it and then disappears when i try to edit some other cell. But when i go click again the cell with combobox it has the selected value that i have entered. Can anyone help.
Tags
Grid
Asked by
xabikos
Top achievements
Rank 1
Share this question
or