This is a migrated thread and some comments may be shown as answers.
dataSource text vs Text
5 Answers 13 Views
This is a migrated thread and some comments may be shown as answers.
Andrei
Top achievements
Rank 1
Andrei asked on 01 Mar 2018, 10:27 AM

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

 

5 Answers, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 05 Mar 2018, 07:25 AM
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.
0
Andrei
Top achievements
Rank 1
answered on 05 Mar 2018, 09:49 AM
Completely and utterly confused after an hour of struggling with it. Reverting to jQuery.map() much easier and clearer. :(
0
Plamen
Telerik team
answered on 06 Mar 2018, 08:14 AM
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.
0
Andrei
Top achievements
Rank 1
answered on 07 Mar 2018, 09:09 AM
broken link or my firewall is not allowing it.
0
Plamen
Telerik team
answered on 07 Mar 2018, 11:05 AM
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.
Tags
Menu
Asked by
Andrei
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Andrei
Top achievements
Rank 1
Share this question
or