在JavaScript中对网格数据进行排序。在sort函数中获取错误

时间:2016-10-05 09:20:22

标签: javascript sorting kendo-ui kendo-grid

我正在尝试对从剑道网格中获取的网格数据进行排序

functionTableGrid = GetGridData("functionTable");
gridData = functionTableGrid.dataSource.data(); // getting the data

排序和调用排序的功能

function sortfunc(a,b) {        
    return a.Description < b.Description;
}
gridData.sort(sortfunc); 

但我收到此错误

TypeError: gridData.sort is not a function

我不确定为什么它不起作用。我在这里张贴了头脑也许头部有一些问题。

<head id="Head1">
<meta http-equiv="X-UA-Compatible" content="IE=10" ie="10">
<title> C&S </title>
<link rel="Stylesheet" href="../Styles/cs.Application.css" type="text/css">
<link rel="Stylesheet" href="../Styles/kendo.common.min.css" type="text/css">
<link rel="Stylesheet" href="../Styles/kendo.default.min.css" type="text/css">
<script src="../JS/jquery.min.js" type="text/javascript">
<script src="../JS/jquery-migrate-1.2.1.js" type="text/javascript">
<script src="../JS/kendo.web.min.js" type="text/javascript">
<script src="../JS/cs.service.js" type="text/javascript">
<script type="text/javascript">
<script src="../JS/cs.base.js" type="text/javascript">
<script src="../JS/cs.service.js" type="text/javascript">
<script src="../JS/cs.mappings.js" type="text/javascript">
<script src="../JS/cs.importexport.common.js" type="text/javascript">
<script src="../JS/cs.router.js" type="text/javascript">
<script src="../JS/cs.admin.workflows.js" type="text/javascript">
<script src="../JS/cs.admin.workflows.data.js" type="text/javascript">
<script type="text/javascript">
<link id="SL_Style" rel="stylesheet" type="text/css" href="chrome://imtranslator/content/css/translator.css">
<style type="text/css">
<style type="text/css">
</head>

1 个答案:

答案 0 :(得分:2)

dataSource.data()返回ObservableArray,这与普通的JavaScript数组不同。

要获取常规JavaScript数组,请使用ObservableArray的toJSON()方法。