Telerik Forums
UI for ASP.NET Core Forum
1 answer
44 views

I use a DropDownList as an EditorTemplate in a Grid.

The problem is, that the DDL has to display several thousand entries (products).

I tried to set the PageSize of the DataSource and handle the Filter-Event. This works fine so far.  The DDL opens very fast and I can search (filter) and then select an entry, that is not visible in the list at the beginning.

This works fine for adding a new record.

But when I want to edit an existing record in the grid I get problems. When the editor opens and the value is not in the select list of the DDL, it is not selected (also not displayed) and the value of the DDL is set to null.

This behavior makes sense to me.

When I remove the PageSize from the DataSource everythings works fine. But it takes to long to open the DDL. That's why I need another solution.

I also tried the virtualization. But the problem stays the same.

Does anyone have an idea how I can solve this?

Maybe another control? Finally the user should be able to search and select a product on an easy way.

I am grateful for any idea.

CPS
Top achievements
Rank 1
Iron
Iron
 answered on 06 Sep 2023
2 answers
271 views

How to cascade DropDownList in Grid?

I've tried a lot of stuff using JavaScript, JQuery and Ajax but I can't get this to work. I wasn't able to find an example on how to do this.

This is my code for grid and editor templates...

@(Html.Kendo().Grid<ToDestination>(Model.ToDestinations)
                .Name("grid")
                .Columns(columns =>
                {
                    columns.ForeignKey(c => c.TravelTypeId,
                    (System.Collections.IList)ViewData["TravelTypes"], "TravelTypeId", "TravelTypeName").Title("Travel Type");

                    columns.ForeignKey(c => c.CountryId,
                    (System.Collections.IList)ViewData["Countries"], "CountryId", "CountryName").Title("Country")
                    .EditorTemplateName("CountryEditor"); // Specify a custom editor template for the Country dropdown.

                    columns.ForeignKey(c => c.PlaceId,
                    (System.Collections.IList)ViewData["Places"], "PlaceId", "PlaceName").Title("Place")
                    .EditorTemplateName("PlaceEditor"); // Specify a custom editor template for the Place dropdown.

                    columns.Bound(c => c.PlaceName);
                    columns.Bound(c => c.CenterName);
                    columns.Command(command => { command.Edit(); command.Destroy(); }).Width(250);
                })
                .ToolBar(toolbar => toolbar.Create())
                .Editable(editable => editable.Mode(GridEditMode.InLine))
                .Pageable()
                .Sortable()
                .Scrollable()
                .DataSource(ds => ds.Ajax()
                .Create(c => c.Url("/TravelOrders/Create?handler=Create").Data("forgeryToken"))
                .Read(r => r.Url("/TravelOrders/Create?handler=Read").Data("forgeryToken"))
                .Update(u => u.Url("/TravelOrders/Create?handler=Update").Data("forgeryToken"))
                .Destroy(d => d.Url("/TravelOrders/Create?handler=Destroy").Data("forgeryToken"))
                .Model(m =>
                {
                    m.Id(id => id.ToDestinationId);
                    m.Field(tt => tt.TravelTypeId).DefaultValue(1);
                    m.Field(c => c.CountryId).DefaultValue(1);
                })
                )
                )

@model int? // Assuming CountryId is nullable

@(Html.Kendo().DropDownList()
    .Name("CountriesList")
    .DataTextField("CountryName")
    .DataValueField("CountryId")
    .BindTo((System.Collections.IEnumerable)ViewData["Countries"])
    .OptionLabel("Select a country")
    .Events(e => e.Change("onCountryChange"))
)

@model int? // Assuming PlaceId is nullable

@(Html.Kendo().DropDownList()
    .Name("PlacesList")
    .DataTextField("PlaceName")
    .DataValueField("PlaceId")
    .BindTo((System.Collections.IEnumerable)ViewData["Places"])
    .OptionLabel("Select a place")
)

Alexander
Telerik team
 answered on 29 Aug 2023
0 answers
47 views

This is partial view:

@model DMDPace.DataAccess.DomainModels.Department

@(Html.Kendo().DropDownListFor(m => m)
    .DataTextField("Name")
    .DataValueField("Id")
    .DataSource(source =>
    {
        source.Read(read =>
        {
            read.Action("GetDepartments", "Home");
        });
    })
    )

That's how I reference it:

<div><partial model="@Model.Department" name="Selectors/Department"/></div>
Why doesn't it appear?
kva
Top achievements
Rank 2
Iron
Iron
Iron
 asked on 07 Aug 2023
1 answer
78 views

I am using a drop down list in column template inside a grid..I could save sucessfully but when i click on edit the dropdown losses its bind.Can any one help  with what i am missing

   <kendo-dropdownlist name="Team"
                                        datatextfield="Team"
                                        datavaluefield="TeamID" data-bind="value:Team">
                        <datasource>
                            <transport>
                                <read url="@Url.Action("Teams_Read", "Grid")" />
                            </transport>
                        </datasource>
                    </kendo-dropdownlist>

 

i chnaged name of the dropdown to the value of what i wante dto bind but it didnt work.

Vasko
Telerik team
 answered on 28 Jul 2023
1 answer
63 views

I have come across scenario that I will have to hide a dropdownlist but need to send the selected value on postback.

Could some one help me with this.

Below is the sample code I am using to load the dropdownlist

@{
                var kendoDropdown = Html.Kendo().DropDownList()
                    .Name("MUAInput")
                    .BindTo(Model.SelectableMUAItems)
                    .DataTextField("Text")
                    .DataValueField("Value")
                    .OptionLabel("Select")
                    .HtmlAttributes(new { name = "MUAInput" });

                if (Model.IsRequired)
                {
                    kendoDropdown.Events(evt =>
                    {
                        evt.Change("onRequiredKendoDropdownChanged");
                    });
                }

            kendoDropdown.HtmlAttributes(new { data_input_required = string.Empty, name = "MUA" });

                kendoDropdown.Render();
            }
Alexander
Telerik team
 answered on 12 Jul 2023
0 answers
48 views

Hello,

I have a DropDownList that I would like to cache based on a radio button 

Code DropDownList :
@(
                    Html.Kendo().DropDownList()
                        .Name("orders")
                        .DataTextField("Companies_name")
                        .DataValueField("CompaniesId")
                        .MinLength(3)
                    .HtmlAttributes(new { style = "width:25%" })
                        .Template("#= CompaniesId # |  #= Companies_name #")
                        .Height(520)
                        .Filter(FilterType.Contains)
                        .DataSource(source =>
                        {
                            source
                            .Ajax()
                            .PageSize(80)
                            .Read("Virtualization_Read", "NewUploadAccount");
                        })
                        .Events(e =>
                        {
                            e.Change("onChange");
                    })
                        .Virtual(v => v.ItemHeight(26).ValueMapper("valueMapper"))
                        )
Regards
Nicolas
Top achievements
Rank 1
Iron
 asked on 12 Jun 2023
1 answer
52 views

I have a grid that is inline editable

My problem is when the drop down appears it looks like this

Some of the items wrap around to two rows.  I would like the drop down to expand to fit the width of the text.

I looked in Chrome and I see the item is in an unnamed div that starts with this

<div class="k-animation-container"

I have tried the following in my .css to override the width of the container

.k-animation-container {
	width: auto;
}

and that doesn't seem to have any effect.

Is there a way to change the width of the drop down when it appears without changing the width of the containing column in the grid?

 

Eric
Top achievements
Rank 2
Iron
Iron
 answered on 31 Mar 2023
2 answers
216 views

I can't seem to get the Cascading DropdownList functionality to return the selected value from the parent.  I will list what I have and if someone can point out my problem I would appreciate it.  The parent loads the selected items correctly, and it calls the child dropdownlist event when a new select is made, but the parameter that should have the selected id is always null.

.cshtml page

<table><tr>
        <td>CLIN:</td>
        <td>

                <kendo-dropdownlist name="ddlCLIN"  datatextfield="Title" datavaluefield="ProjectID" >
                    <datasource type="DataSourceTagHelperType.Custom">
                        <transport>
                            <read url="/LogEditor?handler=CLINS" />
                        </transport>
                    </datasource>

                </kendo-dropdownlist>
            </td>
    </tr>
    <tr>
        <td>CLIN Task Type:</td>
        <td>
            <kendo-dropdownlist name="ddlCLINTaskType" cascade-from="ddlCLIN" datatextfield="Title" datavaluefield="ProjectID">
                <datasource type="DataSourceTagHelperType.Custom">
                    <transport>

                        <read url="/LogEditor?handler=CLINTaskTypes" />

                    </transport>
                </datasource>

            </kendo-dropdownlist>
        </td>
    </tr></table>

 

html.cs

 

public JsonResult OnGetCLINTaskTypes(int? ddlCLIN)
        {
            TaskTypes tt = new TaskTypes(SQLWrapper);
            DataSet ds = new DataSet();
            
            
            if(ddlCLIN == null)
            {
                ddlCLIN = 0;
            }
            ds = tt.SelectRecordsForDropDown("TITLE", Int32.Parse(HttpContext.Session.GetInt32(Globals.SessionName.Org.ToString()).ToString()), ddlCLIN);

            List<Projects> list = new List<Projects>();

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                list.Add(new Projects(SQLWrapper)
                {
                    ProjectID = Convert.ToInt32(dr["TYPE_ID"].ToString()),
                    Title = dr["TITLE"].ToString(),


                });
            }


            var dsResult = list;//.ToDataSourceResult(request);
            return new JsonResult(dsResult);
            
            
        }
        public JsonResult OnGetCLINS()
        {
            Projects Projdb = new Projects(SQLWrapper);
            DataSet ds = new DataSet();
            ds = Projdb.SelectRecordsForDropDown("TITLE", Int32.Parse(HttpContext.Session.GetInt32(Globals.SessionName.Org.ToString()).ToString()));

            List<Projects> list = new List<Projects>();

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                list.Add(new Projects(SQLWrapper)
                {
                    ProjectID = Convert.ToInt32(dr["PROJECT_ID"].ToString()),
                    Title = dr["TITLE"].ToString(),
    

                });
            }

           
            var dsResult = list;//.ToDataSourceResult(request);
            return new JsonResult(dsResult);
        }                                                                          
Aleksandar
Telerik team
 answered on 27 Mar 2023
1 answer
56 views
   

Have a similar scenario as below (taken from example)
https://docs.telerik.com/aspnet-core/html-helpers/data-management/grid/faq

However, in my case, the "additionalData" method is trying to read the values from a Kendo DropDownlist, that has its own .Read method and it appears the Grid is trying to load via its Read method before the dropdown has finished loading via the controller method it calls.  How can I ensure the grids .Data method has all its vallues available before its .Read method is called.  The Dropdown's read method doesnt return in time before it returns its JSON object with one of its values is null and this causes the grid .Read method to take way too long.  

 

// Omitted for brevity.
    .DataSource(dataSource => dataSource.Ajax()
        .Read(read => read
            .Action("Read", "Home")
            .Data("additionalData")
        )
    )
    // Omitted for brevity.
    <script>
        function additionalData() {
            return {
                userID: 42,
                search: $("#search").val()
            };
        }
    </script>

Alexander
Telerik team
 answered on 23 Mar 2023
1 answer
104 views

Hello,

How do I disable popup if no DropDownList/Multiselect contains no data or filtering does not find any items using html helpers:

    @(
        Html.Kendo().DropDownList()
                  .Name("Testi")
                  .DataTextField("Text")
                  .DataValueField("Value")
                  .BindTo(Source)
     )

If I instantate controls using jQuery I would get this done setting noDataTemplate to false:
$("#Testi").kendoDropDownList({ noDataTemplate: false, ..

On html helpers there is no option to set NoDataTemplate boolean value and setting string value empty or null does not work.

Mikko

Aleksandar
Telerik team
 answered on 21 Mar 2023
Narrow your results
Selected tags
Tags
+? more
Top users last month
Mark
Top achievements
Rank 1
Yurii
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Hon
Top achievements
Rank 1
Iron
Deltaohm
Top achievements
Rank 3
Bronze
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Mark
Top achievements
Rank 1
Yurii
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Hon
Top achievements
Rank 1
Iron
Deltaohm
Top achievements
Rank 3
Bronze
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?