dataSource text vs Text

6 posts, 0 answers
  1. Andrei
    Andrei avatar
    3 posts
    Member since:
    Feb 2018

    Posted 01 Mar Link to this post

    Hi Guys,

    .kendoMenu({dataSource: menuItems}); menuItems is JSON from the controller.

    In my C# code, I have the property as Text (capital 'T'), but KendoUI expects a small 't'. I don't want to have properties in my C# starting with small letters. How do I tell Kendo that it should look for 'Text' rather than 'text'?

    Thanks,

    Andrei

     

  2. Plamen
    Admin
    Plamen avatar
    2906 posts

    Posted 05 Mar Link to this post

    Hi Andrei,

    You can use the schema parse method of kendo DataSource and transform the data object according to your needs.

    If you are using MVC backed you can also consider changing the JSON options SerializerSettings acoording to your needs.

    Hope this information will be helpful.

    Regards,
    Plamen
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Andrei
    Andrei avatar
    3 posts
    Member since:
    Feb 2018

    Posted 05 Mar in reply to Plamen Link to this post

    Completely and utterly confused after an hour of struggling with it. Reverting to jQuery.map() much easier and clearer. :(
  4. Plamen
    Admin
    Plamen avatar
    2906 posts

    Posted 06 Mar Link to this post

    Hello,

    Thank you your feedback - yes indeed the example in the documentation is with pure for loop but it can also be used with jQuery map as here.

    Regards,
    Plamen
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  5. Andrei
    Andrei avatar
    3 posts
    Member since:
    Feb 2018

    Posted 07 Mar in reply to Plamen Link to this post

    broken link or my firewall is not allowing it.
  6. Plamen
    Admin
    Plamen avatar
    2906 posts

    Posted 07 Mar Link to this post

    Hello,

    It is the same example with a bit different content of the parse function that uses jQuery map:
    <script>
    var dataSource = new kendo.data.DataSource({
      transport: {
        read: {
          dataType: "jsonp"
        }
      },
      schema: {
        parse: function(response) {
          return $.map(response, function (value){
            return {
              id: value.ProductID,
              name: value.ProductName
            };
          });
        }
      }
    });
    dataSource.fetch(function(){
      var data = dataSource.data();
      var product = data[0];
      console.log(product.name); // displays "Chai"
    });
    </script>


    Regards,
    Plamen
    Progress Telerik
    Try our brand new, jQuery-free Angular 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