“oCol是未定义的”使用Datatables和jQuery Ui对话框 [英] "oCol is Undefined" Using Datatables and jQuery Ui Dialog

查看:145
本文介绍了“oCol是未定义的”使用Datatables和jQuery Ui对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表单,用于搜索注册表。这个表单显示了一个 jQuery对话框中的信息,在对话框的内部,我使用 Datatables (是在对话框内部,我有一个整个表)。我用PHP动态生成TR和TD,然后PHP将该字符串粘贴到HTML中。
但是,当显示对话框时,我收到此错误:


oCol未定义:
oCol.fnSetData oData,val);


我正在Firefox和Chrome中尝试,这是一回事。此外,我在 http://www.datatables.net 中进行了搜索,我丢弃了一个格式错误的表 。我不知道我在做错什么。



你能帮我解决这个问题吗?



这是我的JS块:

 < script type = text / javascriptlanguage =javascriptsrc =lib / jQuery / jquery-1.6.1.js>< / script> 
< script type =text / javascriptlanguage =javascriptsrc =lib / jQuery Ui / js / jquery-ui-1.8.13.custom.min.js>< / script>
< script type =text / javascriptlanguage =javascriptsrc =lib / Datatables / DataTables-1.8.0 / media / js / jquery.dataTables.js>< / script>
< script type =text / javascript>
$(document).ready(function(){
$(#results)。dialog({
title:Results,
width:900,
height:500,
open:function(event,ui){
$(#tRes)。dataTable({
bPaginate:true,
bLengthChange :true,
bFilter:true,
bSort:true,
bInfo:true,
bAutoWidth:true
});
}
});
});
< / script>

这是我的表(带有PHP代码片段):

 < div id =results> 
< table id =tRes>
< thead>
< tr>
< th> ID< / th>
< th> Name< / th>
< th>状态< / th>
< th>地址< / th>
< / tr>
< / thead>
< tbody>
<?php
echo $ rows;
?>
< / tbody>
< / table>
< / div>

感谢Advance。

解决方案

您是否尝试过这样的设置:

  $(#tRes)。dataTable ({
bPaginate:true,
bLengthChange:true,
bFilter:true,
bSort:true,
bInfo true,
bAutoWidth:true,
aoColumns:[
null,
null //放置与列数一样多的空值

]
});

如果这还不行,可以发贴生成的html吗?
您可以考虑的另一件事是在document.ready上初始化表,而不仅仅是打开对话框,但我不认为这是问题。


I have a form, for search a registry. This form, shows the info in a jQuery Dialog, and, inside of the dialog, i am using Datatables (Yes, inside of the dialog i have an entire table). I am generating the TR's and TD's dynamically with PHP, and then, PHP paste the string in the HTML. But, when the dialog is shown i get this error:

oCol is undefined: oCol.fnSetData( oData, val );

I'm trying it in Firefox and Chrome and it's the same thing. Also i've searched in http://www.datatables.net, and i discarded a 'malformed table'. I've no idea of what i'm doing wrong.

Can you Help me with this issue?

This is my JS Block:

        <script type="text/javascript" language="javascript" src="lib/jQuery/jquery-1.6.1.js"></script>
        <script type="text/javascript" language="javascript" src="lib/jQuery Ui/js/jquery-ui-1.8.13.custom.min.js"></script>
        <script type="text/javascript" language="javascript" src="lib/Datatables/DataTables-1.8.0/media/js/jquery.dataTables.js"></script>
        <script type="text/javascript">
            $(document).ready(function (){
                $("#results").dialog({
                    title: "Results",
                    width: 900, 
                    height: 500,
                    open: function(event, ui){
                        $("#tRes").dataTable({
                            "bPaginate": true,
                            "bLengthChange": true,
                            "bFilter": true,
                            "bSort": true,
                            "bInfo": true,
                            "bAutoWidth": true
                        });
                    }
                });
            });
        </script>

This is my Table (With the PHP Snippet):

<div id="results">
    <table id="tRes">
        <thead>
            <tr>
                <th>ID</th>
                <th>Name</th>
                <th>State</th>
                <th>Address</th>
            </tr>
        </thead>
        <tbody>
            <?php 
                echo $rows;
            ?>
        </tbody>
    </table>
</div>

Thanks in Advance.

解决方案

Have you tried settings your Columns like this:

                    $("#tRes").dataTable({
                        "bPaginate": true,
                        "bLengthChange": true,
                        "bFilter": true,
                        "bSort": true,
                        "bInfo": true,
                        "bAutoWidth": true,
                     "aoColumns": [
                                        null,
                                        null //put as many null values as your columns

                    ]
                    });

If this still don't work, can you please post the generated html too? Another thing you could consider is initializing the table on document.ready and not only when you open the dialog, but i don't think that's the issue here.

这篇关于“oCol是未定义的”使用Datatables和jQuery Ui对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆