Telerik Forums
UI for ASP.NET Core Forum
3 answers
427 views

Hi, 

In everything I've read in both the docs and the demos you use a separate controller for the Read and ValueMapper functions associated with the virtualized combobox. The code below is taken from teh virtualizationcontroller.cs in your demo. I am trying to use Razor exclusively and … in theory … I shouldn't need a separate controller class. However, the page I am trying to use the combobox on is the index.cshtml  under areas\identity\pages\account\Manage.

The markup, taken from you demo, for the combo is as follows:

 @(Html.Kendo().ComboBox()
          .Name("orders")
          .DataTextField("ShipName")
          .DataValueField("OrderID")
          .HtmlAttributes(new { style = "width:100%" })
          .Template("#= OrderID # | For: #= ShipName #, #= ShipCountry #")
          .Height(290)
          .DataSource(source => {
              source.Ajax()
                  .PageSize(80)
                  .Read("Virtualization_Read", "ComboBox");
          })
          .Virtual(v => v.ItemHeight(26).ValueMapper("valueMapper"))
    )


Please notice the .Read("Virtualization_Read", "ComboBox"). It's my understanding that "ComboBox" is the controller. How would I point/route that to the razor cshtml.cs file? Right now, if I put the "controller" functions in the .cshtml.cs file they never get called and the combo remains empty. I assume this is because it's not in a controller.

Any guidance or samples would be great!

Thanks … Ed

 

        public ActionResult Virtualization_Read([DataSourceRequest] DataSourceRequest request)
        {
            return Json(GetOrders().ToDataSourceResult(request));
        }
        public ActionResult Orders_ValueMapper(int[] values)
        {
            var indices = new List<int>();
            if (values != null && values.Any())
            {
                var index = 0;
                foreach (var order in GetOrders())
                {
                    if (values.Contains(order.OrderID))
                    {
                        indices.Add(index);
                    }
                    index += 1;
                }
            }
            return Json(indices);
        }
        private IEnumerable<OrderViewModel> GetOrders()
        {
            using (var northwind = GetContext())
            {
                return northwind.Orders.Select(order => new OrderViewModel
                {
                    ContactName = order.Customer.ContactName,
                    Freight = order.Freight,
                    OrderDate = order.OrderDate,
                    ShippedDate = order.ShippedDate,
                    OrderID = order.OrderID,
                    ShipAddress = order.ShipAddress,
                    ShipCountry = order.ShipCountry,
                    ShipName = order.ShipName,
                    ShipCity = order.ShipCity,
                    EmployeeID = order.EmployeeID,
                    CustomerID = order.CustomerID
                }).ToList();
            }
        }
    }

Dimitar
Telerik team
 answered on 04 Apr 2019
3 answers
135 views
I have an inCell Edit grid that has a bound field and a bound checkbox.   When in edit mode, if a change is made to the textbox I want to test the value.   If length(textbox) > 0, set checkbox true, if length(textbox)=0, set checkbox false.    Is this possible?
Tsvetomir
Telerik team
 answered on 04 Apr 2019
2 answers
510 views
Is there a way to disable parent selection?  I only want the user to be able to select one child node.
Petar
Telerik team
 answered on 02 Apr 2019
1 answer
72 views
It seems from your examples and from the dojo tool that the use of the HtmlHelper isn't the preferred way to do things.  Can someone who knows which way this ship is sailing comment on your direction?  Is this the preferred way?  If not, what is the preferred way?
Viktor Tachev
Telerik team
 answered on 02 Apr 2019
1 answer
172 views
With the introduction of Visual Studio 2019 and the significant work put in to Core 3.0 what is the compelling reason to move except to just be on the latest?  Are there new controls or new framework features I should be aware of for ASP.NET Core MVC development that'd prompt me to get there sooner than later?
Veselin Tsvetanov
Telerik team
 answered on 02 Apr 2019
1 answer
299 views

Hello,

When the edit mode is used for other controls, we are given the option to select a template that resides inside of the ~/Views/Shared/EditorTemplates/ folder.I would like to be able to select a template that would be used to display each of the records for this control as well instead of relying on .ClientTemplateId(). Is this currently possible?

For instance, I would like to be able to select the template located at ~/Views/Shared/Templates/ChannelCard.cshtml by doing the following:

@(Html.Kendo().ListView<NotificationSystem.Data.Models.ChannelCard>()
          .Name("channels")
          .TagName("ul")
          .TemplateName("ChannelCard")
          .DataSource(dataSource => dataSource
              .Ajax()
              .Read(read => read.Action("Read", "Channels").Data("bindSearch"))
              .PageSize(20)
          )
          .Pageable()
          .HtmlAttributes(new {@class = "channel-list"})
          .Deferred()
          )
Georgi
Telerik team
 answered on 01 Apr 2019
1 answer
182 views

I am working with AutoComplete in a grid cell. I need the dropdown display for the filter to be different than the value that populates the field once a value is selected. The stored procedure that returns the values to be searched/filtered combines several fields so the users can filter several fields at once. However, I don't want the final selected value displayed to be that field but another shortened field. In my example, the filtering is done on a combination of "ProjectNumber" and "ProjectName" while the final selected value displayed should only be the ProjectNumber.

This isn't an issue once the user presses the Bulk Save button on the grid as the read returns only the ProjectNumber for the grid field but I need to display only the ProjectNumber once an autocomplete value is selected.

@(Html.Kendo().AutoComplete()
        .Name("")
        .Filter(FilterType.Contains)
        .DataTextField("ProjectLookup")
        .Value("ProjectKey")
        .ValuePrimitive(true)
        .Placeholder("Select...")
        .Template("#= ProjectNumber # | #= ProjectName #")
        .AutoWidth(true)
        .MinLength(1)
        .DataSource(dataSource =>
        {
            dataSource.Ajax();
            dataSource.Read(read =>
            {
                read.Action("ProjectAutoComplete_Read", "Timecard").Data("projectAutoCompleteRead");
            })
            .ServerFiltering(false);
        })
        .Events(events => events
            .Select("projectAutoComplete_OnSelect")
            .Filtering("projectAutoComplete_OnFiltering")
            .Change("projectAutoComplete_OnChange")
        )
)

 

 

Misho
Telerik team
 answered on 01 Apr 2019
10 answers
1.5K+ views

I've just set up a grid using ASP.NET core, and the controller method to return data is called, but no data is displayed by the grid. Looking at the JSON returned  in Fiddler, it seems the field name cases have been changed by the serializer to be camel case, with the first letter always being lower case.

 

As the field names of the table are uppercase, this means they aren't being picked up by the grid. The only other option is to serialize as snake case, which doesn't help.

How can this be handled?

Viktor Tachev
Telerik team
 answered on 01 Apr 2019
4 answers
980 views

Hi guys,

I've got a view model that implements IValidatableObject for some DateTime fields that are used with the DateTimePicker. If the validation fails in the Validate method for the DateTime fields they return the error but after fixing the issue (for example DateTime cannot be in the past) the view model and control continues to use a empty/default DateTime value (1-1-1901 12:00 AM) and there's no way to get the model back to a valid state. 

The attached image is the form at start. The two DateTime fields are set to the current time. One you submit the form the Validate method kicks in and recognizes the date in the past and throws back the error message. The second image shows the error message in the form. The third image shows the corrected value to be a time in the future (using the time picker). The fourth image shows the form after the POST where the time gets reset back to 1/1/1901 12:00 AM and throws the error it can't be in the past. No matter how many times you change this field it keeps throwing this error.

Here's the Validate method:

1.public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
2.{
3.        if (OutageStart < DateTime.Now)
4.        {
5.            yield return new ValidationResult("Outage Date / Time cannot appear in the past", new[] { "OutageStart" });
6.        }
7.}
Angel Petrov
Telerik team
 answered on 28 Mar 2019
2 answers
251 views

I have a grid with a popup editor that has lots of content. There is a problem is when you scroll down and the window title is no longer visible. When I make changes to some of the kendo elements in the popup (grid, editor), the browser then scrolls up to the top of the window. 

How can I prevent this scroll up?

Adrian
Top achievements
Rank 1
 answered on 27 Mar 2019
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?