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

Kendo().DropDownListFor extra top row

5 Answers 651 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Rick Hubka
Top achievements
Rank 1
Rick Hubka asked on 26 Oct 2017, 03:26 PM

Hi
May last question of the year.  I promise!  I really don't ask for help much for a long time user.

For my MVC scheduler edit popup I use a CustomEditorTemplate.cshtml because I added 2 extra fields.  Nice!

In that file I use the code below for my OwnerID dropdownlist which usually has 8 items. 
However,  I oftem limit the dropdownlist to only one item when I know the user is filtered to one OwnerID.
So I want the dropdown list to only have that one OwnerID in it automatically selected.  But... for some reason a blank row is at the top of the DDL so the user has to manually select the only one item.  I don't use .OptionLabel("xxx").  How can I get rid of the empty row at the top and make this work?

I can't switch to another ddl control because I need .Data("filterdata")  to pass parameters to.

Thanks

 

 

<div data-container-for="OwnerID" class="k-edit-field">
       @(Html.Kendo().DropDownListFor(model => model.OwnerID)
       .HtmlAttributes(new { data_bind = "value:OwnerID", style = "width: 300px" })
       .DataTextField("Text")
       .DataValueField("Value")
       .ValuePrimitive(true)
       .Template("<span class='k-scheduler-mark' style='background-color:\\#= data.Color?Color:'' \\#'></span>\\#=Text\\#")
       .DataSource(ds => ds
                .Read(read => read
                      .Action("GetDepartmentListx", "Scheduler")
                      .Data("filterdata")  // in index page this function passes checkbox data parameters
                      ))
       )
   </div>

5 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 30 Oct 2017, 12:26 PM
Hello Rick,

I am attaching an ASP.NET MVC solution, where a similar scenario to the one described is demonstrated (Kendo UI Scheduler with custom edit template). With it, the DropDownList inside the custom template correctly sets the corresponding Owner as selected value (the configuration for the DDL is identical to the one provided).

May I ask you to review the implementation and try to incorporate it in your project? In case the issue continues to persist and the blank row selection remains, please modify the solution so that the described issue is reproduced and send it back to us for additional review.

Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Rick Hubka
Top achievements
Rank 1
answered on 30 Oct 2017, 06:25 PM

Hi Dimitar

I have found the problem.
In almost any example for many years now...

change new { Text = "Alex", Value = 1, Color = "#f8a398" } ,
to          new { Text = "Alex", Value = 4, Color = "#f8a398" } ,  // now it does not work.

The Kendo DropDownList will display a default data row if the Value  = 1

Works the same for a hard coded array like above or a call to the database that I use.

My clients  have 8 departments and if the database where clause is for department 1 only it works.  It does not work when the where clause is for department 2 to 8.

I home I can tell my clients that this will be fixed in a future release???

0
Dimitar
Telerik team
answered on 31 Oct 2017, 09:01 AM
Hello Rick,

This behavior can be fixed by removing the below filter from the DataSource:
.Filter(filters =>
{
  filters.Add(model => model.OwnerID).IsEqualTo(1).Or().IsEqualTo(2);
})

I am also attaching an updated version of the previous solution.

Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Rick Hubka
Top achievements
Rank 1
answered on 31 Oct 2017, 05:53 PM

Hi Dimar

Thanks but that does not address my issue and still leaves a blank row at the top of the dropdown list.  Also, I do not want to remove my main window filter for reasons explained below.

I'll step back and explain how my Scheduler is setup.

Similar to the telerik Demo's main page that have 3 people check boxes at the top of the page for filtering.  My page has 8 Department check boxes that work the same and great!.  The filtering is very important to my client because each of the 8 departments has between 15 and 40 tasks every Friday.  Friday is the only day they use.

My Client's weekly staff meetings deal with the department one at a time.  Eg. They Filter on Mechanics (6) and the view now shows only the 35 mechanic tasks.  They now double click to add a new task and my Custom edit window shows so they can add a task to just that mechanic dept (6).  My Edit Kendo().DropDownListFor has a seperate datasouce not with a filter but sourced by a where clause  (Where OwnID = 6).

Yes only OwnerID 6 shows in the drop down but it also has a blank row so department 6 is not auto selected.

The weird thing is that if  in the Custom edit window the (Where OwnerID = 1) then my datasource only retrieves department 1 and now there is no blank row and just department 1 gets autoselected.

It works perfect for 1 but not 7 to 8.

Thanks so much for your patience.

Rick

0
Dimitar
Telerik team
answered on 02 Nov 2017, 08:29 AM
Hello Rick,

I would suggest to open a support thread in the ticketing system, where we can continue our communication. There you can send us an isolated solution, with which the issue with the blank row in the DropDownList is reproduced. Then, we will be able to examine it locally and provide you with a more efficient assistance.

Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Scheduler
Asked by
Rick Hubka
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Rick Hubka
Top achievements
Rank 1
Share this question
or