What object type are selected items?

4 posts, 0 answers
  1. Jason
    Jason avatar
    20 posts
    Member since:
    Aug 2016

    Posted 23 May Link to this post

    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);
     
     
                });
    });

     

  2. Jason
    Jason avatar
    20 posts
    Member since:
    Aug 2016

    Posted 23 May in reply to Jason Link to this post

    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. 
  3. Jason
    Jason avatar
    20 posts
    Member since:
    Aug 2016

    Posted 23 May Link to this post

    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

  4. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    2135 posts

    Posted 25 May Link to this post

    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.
Back to Top