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

virtualization error: Cannot read property 'slice' of undefined

4 Answers 527 Views
MultiColumnComboBox
This is a migrated thread and some comments may be shown as answers.
Renato
Top achievements
Rank 1
Renato asked on 30 Sep 2018, 05:50 PM

hi, 

I am following the example and the documentation, but I can't solve thi issue

 

Uncaught TypeError: Cannot read property 'slice' of undefined
    at init.success (kendo.all.js:7083)
    at success (kendo.all.js:7010)
    at Object.n.success (kendo.all.js:5934)
    at fire (jquery.js:3182)
    at Object.fireWith [as resolveWith] (jquery.js:3312)
    at done (jquery.js:8754)
    at XMLHttpRequest.<anonymous> (jquery.js:9120)

my view:

 

<div class="row">

    <form asp-controller="Home" asp-action="SetLanguage" role="search" method="post">
        <div class="form-group">
            @*<input type="text" placeholder="Search for something..." />*@


            @(Html.Kendo().MultiColumnComboBox()

                       .Name("products")
                       .DataTextField("Name")
                       .DataValueField("Id")
                       .Columns(columns =>
                       {
                       //columns.Add().Field("Name").Template("<a href= '" + "Instrument/Quotes/#: Id #" + "'>Q</a>").Title("Name");
                       //columns.Add().Field("Id").Title("ID");
                       columns.Add().Field("Id").Template("<a href= '" + "/Analisys/AnalisysShort/#: Id #" + "'>#: Name#</a>").Title("ID");

                       })
                       .Placeholder("Search...")
                      .DataSource(source =>
        {
            source.Custom()
                .ServerFiltering(true)
                .ServerPaging(true)
                .PageSize(80)
                .Type("aspnetmvc-ajax")
                .Transport(transport =>
                {
                    transport.Read("SearchInstruments_Read", "Home");
                })
                .Schema(schema =>
                {
                    schema.Data("Data")
                            .Total("Total");
                });
        })
        .Virtual(v => v.ItemHeight(26).ValueMapper("valueMapper")))




            <button type="submit" class="btn btn-success">
                <i class="glyphicon glyphicon-search"></i>
            </button>
        </div>
    </form>
</div>

<script>
        function valueMapper(options) {
            $.ajax({
                url: "@Url.Action("SearchInstruments_ValueMapper", "Home")",
                data: convertValues(options.value),
                success: function (data) {
                    options.success(data);
                }
            });
        }

        function convertValues(value) {
            var data = {};

            value = $.isArray(value) ? value : [value];

            for (var idx = 0; idx < value.length; idx++) {
                data["values[" + idx + "]"] = value[idx];
            }

            return data;
        }
</script>

 

my controller

public async Task<ActionResult> SearchInstruments_Read([DataSourceRequest] DataSourceRequest request)
        {
            var model = await _repo.GetAllAsync<Instrument>();
            var vmodel = Mapper.Map<IEnumerable<InstrumentViewModel>>(model);

            return Json(vmodel);
        }

        public async Task<IActionResult> SearchInstruments_ValueMapper(int[] values)
        {
            var indices = new List<int>();

            if (values != null && values.Any())
            {
                var index = 0;

                foreach (var model in await _repo.GetAllAsync<Instrument>())
                {
                    if (values.Contains(model.Id))
                    {
                        indices.Add(index);
                    }

                    index += 1;
                }
            }

            return Json(indices);
        }

 

thank you for help

4 Answers, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 03 Oct 2018, 02:06 PM
Hello,

I have tested a similar code locally and on our online demo and could not replicate the issue. Would you please try to elaborate a little bit what else should be added or done  to the code from the demo to replicate the issue and be more helpful with a possible solution? Sending as sample runnable project may be helpful too.

Regards,
Plamen
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Renato
Top achievements
Rank 1
answered on 05 Oct 2018, 07:18 AM

Hi plamen thank you for your answer.

Unfortuately I am not able to send you a runnable example.

The issue is an error with javascript kendo when I try to use the virtualiation

I think that it would be great if you could send me your example as a runnable project. Infact in your demo sometimes something is missing and just copyng the example is not enough to make it works.

Thank you

0
Renato
Top achievements
Rank 1
answered on 05 Oct 2018, 11:54 AM

I am interested to have, if is it possible,  a complete sample of this example: https://demos.telerik.com/aspnet-core/multicolumncombobox/tag-helper

thank you 

 

Renato

0
Plamen
Telerik team
answered on 10 Oct 2018, 05:51 AM
Hello Renato,

You can find the sample code for the demo in the offline demos that can be downloaded from your account and found in the 'telerik.ui.for.aspnet.core.2018.3.911.commercial.zip\wrappers\aspnetcore\Examples' directory.

Regards,
Plamen
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
MultiColumnComboBox
Asked by
Renato
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Renato
Top achievements
Rank 1
Share this question
or