Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

kendoui grid assign an array as datasource instead of array of object

I am working with KendoUI grid. I want to assign an array as data-source to the grid instead of using array of objects.

dataSource: [
   [ "User One", 3 ],
   [ "User Two", 3 ]
]

instead of using

dataSource: [
     { name: "User One", age: 3 },
     { name: "User Two", age: 3 }
]

Is this possible?

like image 743
SharpCoder Avatar asked Dec 18 '25 11:12

SharpCoder


1 Answers

It is possible, but it's not completely functional. It only works "to some extent" and certain things won't work(I.E. Editing and selection).

In the linked post they also mention that they don't have any plans to implement it, though that was a few years ago.

var source = [
   [ "User One", 3 ],
   [ "User Two", 33 ]
];

$('#myGrid').kendoGrid({
  columns: [
    { field: "[0]", title: "User" },
    { field: "[1]", title: "Number" }
  ],
  dataSource: {
    data: source
  }
});
<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" href="//kendo.cdn.telerik.com/2015.3.1111/styles/kendo.common-material.min.css" />
  <link rel="stylesheet" href="//kendo.cdn.telerik.com/2015.3.1111/styles/kendo.material.min.css" />
  <script src="//kendo.cdn.telerik.com/2015.3.1111/js/jquery.min.js"></script>
  <script src="//kendo.cdn.telerik.com/2015.3.1111/js/kendo.all.min.js"></script>
</head>
<body>
    
    <div id="myGrid"></div>

</body>
</html>
like image 57
Jon Avatar answered Dec 20 '25 12:12

Jon