Telerik Forums
Kendo UI for jQuery Forum
0 answers
204 views

Update

This should be a UI for ASP.NET Core question, so I Reposted it here

Scenario:

I am trying to enable and disable CheckBoxGroup items,

and it dependes on whether if the categories of the item has values.

For example, If there are two categorie, which are animals and fruits.

If I recieved no datas of fruits, I'll disabled the CheckBoxGroup item "fruits".

What I've tried so far

I search through documents and found this tutorial of the BindTo() method,

However, I got an error message saying "Cannot convert from System.Collections.Generic.List<MyCheckBoxItemModel> to string []

Questions

1. According to the method, how can I convert List<model> to string[] in my .cshtml ?

2. (Extension Question) In the tutorial, I'm awared that in the "InputGroupItemModel" there was a "Enabled" attribute.

Is it mean that if passed it to the front end and attached it with the BindTo() method, the CheckBoxGroup will automatically enable or disable the checkbox item?

(I'll show my code below)

Code

CheckBoxItemDto.cs

 public class CheckBoxItemDto
    {
        //public IDictionary<string, object> HtmlAttributes { get; set; }

        //public string CssClass { get; set; }

        public bool? Enabled { get; set; }

        //public bool? Encoded { get; set; }

        public string Label { get; set; }

        public string Value { get; set; }
    }

CheckBoxItemViewModel.cs

public class CheckBoxItemViewModel
    {
        public List<CheckBoxItemDto> Items { get; set; }

        public string[] CheckBoxGroupValue { get; set; }
    }

MyViewModel.cs

public class EqInstsDataViewModel
    {
        public IEnumerable<MyOtherViewModel> MyOtherViewModel { get; set; }
        public CheckBoxItemViewModel CheckBoxItemViewModel { get; set; }
    }

Controller

 

public IActionResult GetChartPartialView() { try { List<CheckBoxItemDto> checkBoxItemDto = GetCheckBoxItem(); //Get CheckBox Items

CheckBoxItemViewModel checkBoxItem = new CheckBoxItemViewModel() { Items = checkBoxItemDto }; MyViewModel myViewModel = new MyViewModel() { Items = checkBoxItem } return PartialView("~/Views/Shared/_MyPartialView.cshtml", myViewModel); } catch (Exception ex) { return Json(ex.Message); } }


public List<CheckBoxItem> GetCheckBoxItem()
        {            
            try
            {
                #region CheckBoxItems

                var itemsList = new List<CheckBoxItemDto>()
                {
                    new CheckBoxItemDto()
                    {
                        Label = "Animals",
                        Value = "1",
                        Enabled = true
                    },
                     new CheckBoxItemDto()
                    {
                        Label = "Friuts",
                        Value = "2",
                        Enabled = false
                    } ,
                };

                #endregion

                return itemList;
            }
            catch(Exception)
            {
                throw;
            }
        }

 

_MyPartialView.cshtml

@(Html.Kendo().CheckBoxGroup()     
        .Name("MyCheckBox")
        .BindTo(Model.CheckBoxItemViewModel.Items)  //Cannot convert from List<CheckBoxItemDto> to string[]
        .Value(Model.CheckBoxItemViewModel.CheckBoxGroupValue)
        .Layout("horizontal")
     )

CHIHPEI
Top achievements
Rank 2
Iron
Iron
Iron
 updated question on 04 Jan 2023
1 answer
114 views
I am new to Kendo and I don't know if kendo just doesn't allow for it yet or not but I have tried using HtmlHelpers, TagHelpers and JQuery but I can't get any of them to function as I would expect. If anybody has an example of how to submit data using Razor Pages and JQuery spreadsheet, I would appreciate it. There isn't much reference material on it or at least, not that I can find. I want to bind a list of a class to the spreadsheet and whatever they submit will be added to a database
Neli
Telerik team
 answered on 03 Jan 2023
1 answer
100 views

Would like to check if I am able to achieve this layout using the kendo grid, or any other control of kendo?

 

Nikolay
Telerik team
 answered on 02 Jan 2023
0 answers
135 views

Hi,

I checked your  AutoComplete and MultiColumnComboBox examples.But any example , you did not send a parameter to Controller using by UI Jquery AutoComplete and MultiColumnCombobox.How to send a parameter to Controller for server filtering? When I try to implement your example codes, The parameter i send to controller returns null.


Zafer
Top achievements
Rank 1
 asked on 29 Dec 2022
1 answer
164 views

Hi

i need change Font and Rotation labels in yAxis , but not applying

Dojo Example

this problem also exists in xAxis mode

Dojo Example

 

thank you

Peter Milchev
Telerik team
 answered on 28 Dec 2022
0 answers
170 views

we have a field in which the source value is an array of objects, to edit it we use kendoMultiSelect, to show we just concat the values:

 


this.MultiSelectEmployeeClassesArrayToString = function (item) {
            return item.EmployeeLicensingClasses
                .map(function (employeeClass) { return employeeClass.Description; })
                .join(', ');
        },

is there a way to make filtering work as a contains for example & sort just the value we display (concatenating)?

 

Aleksandr
Top achievements
Rank 1
Bronze
Bronze
Veteran
 asked on 28 Dec 2022
2 answers
234 views

What is the best way to customize the timestamp location and format?

We've tried using templates but can only control those rendered from chat.renderMessage, it's not clear how to use a different template from the user's posted message (ie we only know how to control the left-side not the right-side message bubbles)

The documentation has no information on this and were only able to piece together from other forum posts

Peter Milchev
Telerik team
 answered on 27 Dec 2022
3 answers
1.8K+ views

Hello, I am having a hard time getting this to work even after following solutions such as these:

 

http://docs.telerik.com/aspnet-mvc/helpers/grid/how-to/Export/detail-grid-export

 

I have a main grid, and detail grid that can go up to 5 levels down, and wish to export the child data as well as the main data in the same workbook.  I have attached what my actual grid looks like in action (had to redact some text):

 

Main Grid:

@(Html.Kendo().Grid<...>()
        .Name("...")
        .Scrollable(s => s.Height("auto"))
        .HtmlAttributes(new { @class = "hidden", style = "height: 100%" })
        .Columns(columns =>
        {
            columns.Bound(...)
        .ClientDetailTemplateId("gridTemplate")
        .Events(e => e.DataBound("onMainGridDataBound").ExcelExport("onMainGridExcelExport").DetailInit("onMainGridDetailInit"))
        .Sortable()
        .Excel(xls => xls.FileName("Export.xlsx"))
        .Pdf(pdf => pdf.FileName("Export.pdf"))
        .DataSource(dataSource => dataSource
            .Ajax()
            .Model(model =>
            {
                ...
            })
            .Group(...)
            .Read(read => read.Type(HttpVerbs.Post).Action("..", "Grid").Data("..."))
            .Events(events =>
            {
                events.RequestEnd("onMainGridRequestEnd");
                events.Error("onError");
            })
        )
    )

 

Detail Grid:

<script type="text/x-kendo-template" id="gridTemplate">
    @(Html.Kendo().Grid<...>()
        .Name("..._#=UniqueId#")
        .Columns(columns =>
        {
            columns.Bound(...)
        .Pageable()
        .Sortable()
        .Excel(xls => xls.FileName("Detail Export.xlsx"))
        .ClientDetailTemplateId("gridTemplate")
        .Events(e => e.DataBound("onMainGridDataBound").ExcelExport("onDetailGridExcelExport").DetailInit("onMainGridDetailInit"))
        .ToClientTemplate()
    )
</script>

 

Stevan
Top achievements
Rank 1
Iron
Iron
 answered on 26 Dec 2022
0 answers
118 views

Hello!

I could not manage to implement a combobox widget with virtualization if the text/value fields are set with values which are not in the datasoruce:

Here is an example code:


        $("#orders").kendoComboBox({
                template: '#= OrderID # | #= ShipName #',
                dataTextField: "ShipName",
                dataValueField: "OrderID",
              	text: 'Not in the list',
                value: 0,
                virtual: {
                    itemHeight: 26,
                    valueMapper: function(options) {
                        $.ajax({
                            url: "https://demos.telerik.com/kendo-ui/service/Orders/ValueMapper",
                            type: "GET",
                            dataType: "jsonp",
                            data: convertValues(options.value),
                            success: function (data) {
                                options.success(data);
                            }
                        })
                    }
                },
                height: 520,
                dataSource: {
                    type: "odata",
                    transport: {
                        read: "https://demos.telerik.com/kendo-ui/service/Northwind.svc/Orders"
                    },
                    pageSize: 80,
                    serverPaging: true,
                    serverFiltering: true
                }
            });

Robert
Top achievements
Rank 1
 asked on 23 Dec 2022
2 answers
618 views

Requirements:

 

We have to create a Kendo Ui JQuery Wizard with dynamic number of steps. We want to develop the registration page exactly like:

tps://demos.telerik.com/aspnet-ajax/wizard/application-scenarios/add-remove-wizardsteps/defaultcs.aspx 

 

But it has to be in Kendo UI JQuery Wizard. Can you please guide me how to achieve this. I have tried the following code but it is not working.

 

Please see the attached code.

 

Thank you,

Gururaj

 

Gururaj
Top achievements
Rank 1
Iron
 updated answer on 21 Dec 2022
Narrow your results
Selected tags
Tags
+? more
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?