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

What object type are selected items?

3 Answers 56 Views
MultiSelect
This is a migrated thread and some comments may be shown as answers.
Jason
Top achievements
Rank 1
Jason asked on 23 May 2017, 03:05 PM

I used the MVC example which works perfect as-is I rewrote to work with a JSON request and it ALSO works fine, however when I try to view the data in a string it is trying to display the OBJECT and not the data inside the object. I ASSUMED that the SelectedData is also in JSON format becuase the MultiSelect datasourse is a JSON object.  

 

@(Html.Kendo().MultiSelect()
         .Name("GridSelect")         
         .AutoClose(false)
         .Placeholder("Select Which Grids to Print...") 
         .DataTextField("MapName")
         .DataValueField("Pagenumber")
         .DataSource(source =>
                     {
                         source.Read(read =>
                         {
                             read.Action("GetCascadeGrid100", "GridPrint")
                             .Data("filterGrid100");
                         })
                         .ServerFiltering(true);
                     })       
   )

 

 

So my issue is when I create click button function and I want to display the selected items..  here is what I have tried and the results.  I just want to display my data in a string   Mapname:1 PageNumber:234, Mapname:3, PageNumber:3244 etc...  

 

$(document).ready(function () {
              
            var Gridselect = $("#GridSelect").data("kendoMultiSelect");
 
 
            
 
            $("#get").click(function () {
 
              alert( Gridselect.value + ",  "  + Gridselect.text + ",");
  // this displays nothing but the commas
 
// Also have tried
 
               var output = '';
                for (var entry in Gridselect) {
                    output += 'key: ' + entry + ' | value: ' + Gridselect[entry] + '\n';
                }
 
                alert(output);
// This displays a bunch of data but none of my values, it seems to parse the PageNumber and the MapName so there is something in there.
 
// Also Tried 
 
            alert(Gridselect.toSource);
 
 
            });
});

 

3 Answers, 1 is accepted

Sort by
0
Jason
Top achievements
Rank 1
answered on 23 May 2017, 04:06 PM
I noticed a stupid syntax error on the DataValueField it should have been PageNumber, so I am getting the Gridselect.value to display, however if I try to call the Gridselect.text I get an error saying text is not a function. 
0
Jason
Top achievements
Rank 1
answered on 23 May 2017, 06:12 PM

I'm getting closer..  this gets me all the VALUES but only One of the Text Items

alert("value: " + Gridselect.value() + "\n" + "text: " + Gridselect.dataItem().MapName); 

 

So my results looks something like this:

Value:123,343,456,654,754

text: Map1

 

I should have Map1, Map2, Map3, Map4, Map5

0
Konstantin Dikov
Telerik team
answered on 25 May 2017, 08:51 AM
Hello Jason,

As documented in the following help topic, the dataItems method will return a collection with the selected data items, so you need to traverse all items in that collection for retrieving the MapName values:
Hope this helps.


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