2

I am trying to render correctly a Kendo grid that gets it's data from my store.

The resources I have used are:

Vuex How to bind store to KendoUi-Vue Grid in transport read

https://www.telerik.com/blogs/get-more-out-of-vue-kendo-ui-using-vuex

This is what I have tried:

<template>
     <div>
        <kendo-grid :data-source="kendoDataSource" ref="gridComponent">
                <kendo-grid-column field="id" title="ID" :width="200" :hidden="true"></kendo-grid-column>
                <kendo-grid-column field="name" title="Name" :width="200"></kendo-grid-column>
                <kendo-grid-column field="type" title="Type"></kendo-grid-column>
        </kendo-grid>
     </div>
</template>
<script>
    import {mapGetters} from 'vuex';
    export default {
      computed: {
        ...mapGetters({
            items: 'widgets/getWidgets'
        }),
         kendoDataSource() { 
            let items = this.items;
            return new kendo.data.DataSource({
                data: items
            })
         }
      }
    }
</script>

With this I got a linting error: 'kendo' is not defined (no-undef)

But I got this rendered: enter image description here

So a grid with four rows, the same as my number of items in my store. But also, when I tried returning this in the computed section:

return {
           schema: {
              data: function (response) {
                  return response;
              },
              model: {
                  id: "id",
                  fields: {
                       id: { type: "number" },
                       name: { type: "string" },
                       type: { type: "string" },
                       data: { type: "string" }
                  }
               }
              },
              transport: {
                   read: function (options) {
                            options.success(items);
                   }
              }
        }

I also got 4 empty rows, and the response in the data function is exactly the correct information, an array of 4 items:

[{
    "id": 1,
    "name": "Richard Parker",
    "type": "Tiger",
    "data": "{}"
  },
  {
    "id": 2,
    "name": "Shere Khan",
    "type": "Tiger",
    "data": "{}"
  },
  {
    "id": 3,
    "name": "Simba",
    "type": "Lion",
    "data": "{}"
  },{
    "id": 4,
    "name": "Garfield",
    "type": "Cat",
    "data": "{}"
  }]

I also tried returning items from kendoDataSource(), also got 4 emtpy rows....

Roger Federer
  • 329
  • 2
  • 6
  • 12

0 Answers0