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

How can I show DropDownList as the default column type in GridView initial loading for all rows ?

3 Answers 60 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rob
Top achievements
Rank 1
Rob asked on 10 Nov 2016, 11:25 PM
Hi,
I'd like to know how can I show DropDownList as the default control type for specific column in GridView control on its initial loading instead of showing the default label in each row for specific column.
I'm using in-cell edit mode and I followed your demos to show DropDownList for specific column by using ClientTemplate and ForeignKey Column Type ..Its working good, However, I'd like to show this DropDownList always for this columns in all rows in GridView initial loading not only when focus on the related cell.

View.cshtml:

@(Html.Kendo().Grid<MyModels.Models.ViewModels.ProductCategoryViewModel>()
    .Name("grid")
    .Columns(columns =>
    {
        columns.Bound(p => p.ProductName);
        columns.Bound(p => p.Category).ClientTemplate("#=Category.CategoryName#").Width(160);
        columns.Bound(p => p.UnitPrice).Width(120);
        columns.Command(command => command.Destroy()).Width(90);
    })
    .ToolBar(toolBar =>
        {
            toolBar.Create();
            toolBar.Save();
        })
    .Editable(editable => editable.Mode(GridEditMode.InCell))
    .Pageable()
    .Sortable()
    .Scrollable()
    .HtmlAttributes(new { style = "height:430px;" })
    .DataSource(dataSource => dataSource
        .Ajax()
        .Batch(true)
        .ServerOperation(false)
        .Events(events => events.Error("error_handler"))
        .Model(model =>
        {
            model.Id(p => p.ProductID);
            model.Field(p => p.ProductID).Editable(false);
        })
        .PageSize(20)
                .Read(read => read.Action("GetAllProductsAndRelatedCategories", "Product"))
                .Create(create => create.Action("AddProductsAndRelatedCategories", "Product"))
                .Update(update => update.Action("UpdateProductsAndRelatedCategories", "Product"))
                .Destroy(destroy => destroy.Action("RemoveProductsAndRelatedCategories", "Product"))
    )
)

3 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 14 Nov 2016, 11:34 AM
Hello Rob,

When using InCell editing mode, the user should first click to cell in order to open it for editing:
http://demos.telerik.com/aspnet-mvc/grid/editing

Anything else would be a custom implementation. For example, you can check the attached application for a possible approach with checkbox column.

Regards,
Eyup
Telerik by Progress
Check out the new UI for ASP.NET Core, the most complete UI suite for ASP.NET Core development on the market, with 60+ tried-and-tested widgets, based on Kendo UI.
0
Rob
Top achievements
Rank 1
answered on 16 Nov 2016, 10:23 AM
Hi Eyup,
Thanks for your reply and support.
I'd like to know if there is any workaround to show dropdownlist as default column type in normal view not in edit only ?
0
Eyup
Telerik team
answered on 18 Nov 2016, 06:44 AM
Hi Rob,

You can try using ClientTemplates to achieve this requirement:
http://docs.telerik.com/aspnet-mvc/helpers/grid/faq#how-to-use-kendo-ui-widgets-inside-grid-client-column-templates

Regards,
Eyup
Telerik by Progress
Telerik UI for ASP.NET MVC is ready for Visual Studio 2017 RC! Learn more.
Tags
Grid
Asked by
Rob
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Rob
Top achievements
Rank 1
Share this question
or