jQuery 数据表调整大小问题

发布于 2024-10-14 18:22:44 字数 4884 浏览 2 评论 0原文

我的 Jquery 数据表有问题。基本上我想要一个像这样的数据表: 数据表示例

我导入了这些在我的代码中:

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<script src="scripts/jquery-1.4.4.min.js" type="text/javascript"></script>
<script src="scripts/jquery.dataTables.min.js" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function() {
        $('#example').dataTable({
            "bJQueryUI": true,
            "sPaginationType": "full_numbers",
            "oLanguage": {
            "sLengthMenu": "Sayfada _MENU_ kayıt göster",
            "sZeroRecords": "Kayıt bulunamadı",
            "sInfo": "_TOTAL_ kayıttan _START_ - _END_ arası  gösteriliyor",
            "sInfoEmpty": "toplam 0 kayıt arasında 0 - 0 arası kayıt gösteriliyor",
            "sInfoFiltered": "(toplam _MAX_ kayıt arasında filtreleme yapıldı)"
        }
        });
        $("#submit").click(function(event) {
            var course = $("#courses :selected").val();
            var instructor = $("#instructors :selected").val();
            $.ajax({
                type:'POST',
                url: 'assignCourse.action',
                data: { pageAction:"assignCourse" , courseIdStr: course, instructorIdStr: instructor },
                success: function(data) {
                    if (data == null || data == '') {
                        alert('Ders Atama İşlemi Başarıyla Gerçekleştirildi!');
                    } else {
                        alert(data);
                    }
                },
                error: function(data) {
                    alert('İşlem Gerçekleştirilirken Hata Oluştu!');
                }
            });
        });
    });
</script>
<title>Ders Atama Modülü</title></head>
<link href="CSS/style.css" rel="stylesheet" type="text/css" />
<link href="CSS/custom-theme/jquery-ui-1.8.9.custom.css" rel="stylesheet" type="text/css" />
<link href="CSS/demo_page.css" rel="stylesheet" type="text/css" />
<link href="CSS/demo_table_jui.css" rel="stylesheet" type="text/css" />
<body>
<h1>Ders Atama Modülü</h1>
</body>
<table>
<tr>
    <td class="oyun_yazari" height="30" width="20">Ders:</td>
    <td width="200">
        <div>
            <select id="courses">
            <s:iterator value="courseGroups" status="stat">
             <option value="<s:property value='courseGroupId'/>"><s:property value='course.name'/> - <s:property value='groupNumber'/>. grup</option>
            </s:iterator>
            </select>
        </div>
    </td>
    <td class="oyun_yazari" height="30" width="20">Akademisyen:</td>
    <td width="274">
        <div>
            <select id="instructors">
            <s:iterator value="instructors" status="stat">
                <option value="<s:property value='instructorId'/>"><s:property value='instructorName'/> <s:property value='instructorSurname'/></option>
            </s:iterator>
            </select>
        </div>
    </td>
</tr>
<tr>
    <td>
        <div>
            <input type="submit" name="submit" id="submit" value="Ata"/>
        </div>
    </td>
</tr>
</table>
<table id=example>
<thead>
<tr>
<th>Ders Adı</th><th>Grup</th><th>Akademisyen</th><th>Sil</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Ders Adı</th><th>Grup </th><th>Akademisyen</th><th>Sil </th>
</tr>
</tfoot>
<tbody>
    <s:iterator value="assignedInstructors" status="stat">
    <tr>
        <td><s:property value='courseGroup.course.name'/></td>
        <td><s:property value='courseGroup.groupNumber'/></td>
        <td><s:property value='instructor.instructorName'/> <s:property value='instructor.instructorSurname'/></td>
        <td><input type="checkbox"/></td>
    </tr>
    </s:iterator>
    <!--
    <tr>
        <td><div><input type="submit" name="sil" id="sil" value=" Seçili Atanmış Dersleri Sil" /></div></td>
    </tr>
    -->
</tbody>
</table>
</html>

style.css 是我的,其他的取自 datatable api 和 jquery css 代码。

当我运行该程序时,我得到如下页面: screenshot PS:我的页面位于 iframe 中。

感谢您的帮助。

I have a problem with my Jquery Datatable. Basically I want to have a datatable like that: Data table example

I imported these at my code:

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<script src="scripts/jquery-1.4.4.min.js" type="text/javascript"></script>
<script src="scripts/jquery.dataTables.min.js" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function() {
        $('#example').dataTable({
            "bJQueryUI": true,
            "sPaginationType": "full_numbers",
            "oLanguage": {
            "sLengthMenu": "Sayfada _MENU_ kayıt göster",
            "sZeroRecords": "Kayıt bulunamadı",
            "sInfo": "_TOTAL_ kayıttan _START_ - _END_ arası  gösteriliyor",
            "sInfoEmpty": "toplam 0 kayıt arasında 0 - 0 arası kayıt gösteriliyor",
            "sInfoFiltered": "(toplam _MAX_ kayıt arasında filtreleme yapıldı)"
        }
        });
        $("#submit").click(function(event) {
            var course = $("#courses :selected").val();
            var instructor = $("#instructors :selected").val();
            $.ajax({
                type:'POST',
                url: 'assignCourse.action',
                data: { pageAction:"assignCourse" , courseIdStr: course, instructorIdStr: instructor },
                success: function(data) {
                    if (data == null || data == '') {
                        alert('Ders Atama İşlemi Başarıyla Gerçekleştirildi!');
                    } else {
                        alert(data);
                    }
                },
                error: function(data) {
                    alert('İşlem Gerçekleştirilirken Hata Oluştu!');
                }
            });
        });
    });
</script>
<title>Ders Atama Modülü</title></head>
<link href="CSS/style.css" rel="stylesheet" type="text/css" />
<link href="CSS/custom-theme/jquery-ui-1.8.9.custom.css" rel="stylesheet" type="text/css" />
<link href="CSS/demo_page.css" rel="stylesheet" type="text/css" />
<link href="CSS/demo_table_jui.css" rel="stylesheet" type="text/css" />
<body>
<h1>Ders Atama Modülü</h1>
</body>
<table>
<tr>
    <td class="oyun_yazari" height="30" width="20">Ders:</td>
    <td width="200">
        <div>
            <select id="courses">
            <s:iterator value="courseGroups" status="stat">
             <option value="<s:property value='courseGroupId'/>"><s:property value='course.name'/> - <s:property value='groupNumber'/>. grup</option>
            </s:iterator>
            </select>
        </div>
    </td>
    <td class="oyun_yazari" height="30" width="20">Akademisyen:</td>
    <td width="274">
        <div>
            <select id="instructors">
            <s:iterator value="instructors" status="stat">
                <option value="<s:property value='instructorId'/>"><s:property value='instructorName'/> <s:property value='instructorSurname'/></option>
            </s:iterator>
            </select>
        </div>
    </td>
</tr>
<tr>
    <td>
        <div>
            <input type="submit" name="submit" id="submit" value="Ata"/>
        </div>
    </td>
</tr>
</table>
<table id=example>
<thead>
<tr>
<th>Ders Adı</th><th>Grup</th><th>Akademisyen</th><th>Sil</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Ders Adı</th><th>Grup </th><th>Akademisyen</th><th>Sil </th>
</tr>
</tfoot>
<tbody>
    <s:iterator value="assignedInstructors" status="stat">
    <tr>
        <td><s:property value='courseGroup.course.name'/></td>
        <td><s:property value='courseGroup.groupNumber'/></td>
        <td><s:property value='instructor.instructorName'/> <s:property value='instructor.instructorSurname'/></td>
        <td><input type="checkbox"/></td>
    </tr>
    </s:iterator>
    <!--
    <tr>
        <td><div><input type="submit" name="sil" id="sil" value=" Seçili Atanmış Dersleri Sil" /></div></td>
    </tr>
    -->
</tbody>
</table>
</html>

style.css is mine, others are taken from datatable api and jquery css codes.

When I run the program I get a page like these: screenshot
Ps: My page is in an iframe.

Thanks for your help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

往昔成烟 2024-10-21 18:22:44

标记替换为

。或者,您可以将它们添加到您的 css 文件中。 cellspacing 属性将消除行和列之间的空白空间问题。 width 属性是解决右对齐问题的另一种方法。

如果您仍然遇到列太窄的问题,您可以使用 aoColumns 和 sWidth 参数手动设置列宽度 (文档在这里)。

编辑:此外,如果您使用默认的 .css 文件,那么如果您希望鼠标悬停时指针出现在表格标题中,则需要为表格指定“display”类。换句话说,将 class="display" 添加到 标记中。

Replace your <table> tag with <table cellspacing="0px" width="100%">. Alternatively, you could add these to your css file. The cellspacing attribute will eliminate your problem of the empty space between the rows and columns. The width attribute is another way you could solve the right alignment problem.

If you are still having issues with the columns being too narrow, you can manually set the column widths with the aoColumns and sWidth parameters (documentation here).

edit: Also, if you are using the default .css files, then if you want the pointer to appear in the table header when you hover, you need to give your table the 'display' class. In other words, add class="display" to your <table> tag.

み格子的夏天 2024-10-21 18:22:44

对列标题进行排序。

简短的答案是应用样式表 demo_page.css

demo_table.css

严格来说,demo_page.css 中需要几行。

To sort out the column titles.

The short answer is to apply the style sheet demo_page.css and

demo_table.css.

Strictly speaking couple lines in demo_page.css is required.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文