jqGrid tableToGrid函数

时间:2011-07-21 16:08:33

标签: jqgrid

我找不到一个如何使用tableToGrid函数的简单示例(或至少我无法运行我的样本)。 有人可以帮忙吗? 这是我的HTML测试:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>


    <script type="text/javascript" src="/Content/Scripts/jquery-1.4.4.js"></script>
    <script type="text/javascript" src="/Content/Scripts/jqGrid/jquery.jqGrid.min.js"></script>
<script type="text/javascript" src="/Content/Scripts/jqGrid/grid.locale-en.js"></script>
<script type="text/javascript" src="/Content/Scripts/jqGrid/grid.base.js"></script>
<script type="text/javascript" src="/Content/Scripts/jqGrid/jqDnR.js"></script>
</head>
<body>
<table id="table" class="classname">
<tr><td>bla</td><td>2nd td</td><td>3rd td</td></tr>
<tr><td>bla</td><td>2nd td</td><td>3rd td</td></tr>
<tr><td>bla</td><td>2nd td</td><td>3rd td</td></tr>
<tr><td>bla</td><td>2nd td</td><td>3rd td</td></tr>
</table>

<script type="text/javascript">
    //    debugger;
    //    tableToGrid('#classname', {});

    $(document).ready(function () { tableToGrid(".table"); });


</script>
</body>
</html>

更新:在查看示例(并将'。'更改为'#')之后,我在表中添加了一些元素并且它有效。这是经过修改的HTML:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
<!--    <link rel="stylesheet" href="/Content/Styles/jsTree/style.css" type="text/css" />

    <script type="text/javascript" src="/Content/Scripts/jsTree/jquery.cookie.js"></script>
    <script type="text/javascript" src="/Content/Scripts/jsTree/jquery.hotkeys.js"></script>
    <script type="text/javascript" src="/Content/Scripts/jsTree/jquery.jstree.js"></script>-->

    <script type="text/javascript" src="/Content/Scripts/jquery-1.4.4.js"></script>
    <script type="text/javascript" src="/Content/Scripts/jqGrid/jquery.jqGrid.min.js"></script>
<script type="text/javascript" src="/Content/Scripts/jqGrid/grid.locale-en.js"></script>
<script type="text/javascript" src="/Content/Scripts/jqGrid/grid.base.js"></script>
<script type="text/javascript" src="/Content/Scripts/jqGrid/jqDnR.js"></script>
</head>
<body>

<input type="button" id="button" /> 

<table id="table" class="classname" border="1">
<thead>
<tr><th>sdfsdf</th><th>sdfgfdgdf</th><th>sdgfdfsgdfg</th></tr></thead>
<tbody>
<tr><td>bla</td><td>2nd td</td><td>3rd td</td></tr>
<tr><td>bla</td><td>2nd td</td><td>3rd td</td></tr>
<tr><td>bla</td><td>2nd td</td><td>3rd td</td></tr>
<tr><td>bla</td><td>2nd td</td><td>3rd td</td></tr>
</tbody>
</table>

<script type="text/javascript">

   // $("#button").click(function () { tableToGrid("#table"); });
    //$("#button").click(function () { tableToGrid("#table"); });
    $(document).ready(function () { tableToGrid("#table"); });

</script>
</body>
</html>

1 个答案:

答案 0 :(得分:1)

在您的代码中,您需要使用它的ID引用该表:

tableToGrid("#table")

供参考,tableToGrid下有New in version 3.3 here的工作演示版。 HTML Table to Grid。您可以在Web上查看他们的代码,也可以下载演示并在本地运行它们。