jquery 数据表 Ajax-Error / http://datatables.net/tn/7

jquery datatables Ajax-Error / http://datatables.net/tn/7

请看下面我的问题:

我在 MVC-Web-Applikation 中使用 jquery 数据表。当我只显示 8 列时,一切正常。但是多了 1 列,我得到了 ajax-error-message,见标题。

控制器工作正常,因为 8 列工作正常。这是我的视图代码:

<script type="text/javascript">
    $(document).ready(function () {
        var table = $('#example').DataTable({
            "processing": true,
            "serverSide": true,
            "ajax": "@Url.Action("List", "DFS_Akustik")",
            "columns": [
                { "data": "ID" },
                { "data": "MessID" },
                { "data": "KL_ID" },
                { "data": "MP_ID" },
                { "data": "LwLin50ss" },
                { "data": "LwLin63ss" },
                { "data": "LwLin80ss" },
                { "data": "LwLin100ss" },
                //{ "data": "LwLin125ss" },
            ],
        });
    });
</script>

您可以,最后一列未激活,然后:

http://ziehl-abegg.com/files/work.jpg

当我删除最后一列的 // 时,然后:

http://ziehl-abegg.com/files/work_not.jpg

我该如何解决这个问题??请帮助我...我正在寻找解决方案,从星期一开始,一整天!!

谢谢。

问候 Vegeta_77

早上好。这里的 HTML / table header:

<div style="width: auto; height: 750px; overflow-x: auto; overflow-y: auto;">
    <table id="example" class="table display" cellspacing="0">
        <thead>
            <tr>
                <th>ID</th>
                <th>MessID</th>
                <th>KL_ID</th>
                <th>MP_ID</th>
                <th>LwLin50ss</th>
                <th>LwLin63ss</th>
                <th>LwLin80ss</th>
                <th>LwLin100ss</th>
                @*<th>LwLin125ss</th>*@
            </tr>
        </thead>
    </table>
</div>

服务端效果不错,看:

http://ziehl-abegg.com/files/ServerSide.jpg

@西皮。我不明白我们的第二个问题。

名字都对,看第三个picture/link。 这是来自控制器的方法 "List":

public JsonResult List([ModelBinder(typeof(DataTablesBinder))] 
IDataTablesRequest requestModel)
{
List<View_DFS_Akustik> myOriginalDataSet = dbman.View_DFS_Akustik.ToList();
List<View_DFS_Akustik> myFilteredData = dbman.Set<View_DFS_Akustik>().FullTextSearch(requestModel.Search.Value).ToList();

//Apply filter to your dataset based only on the columns that actually have a search value.
foreach (var column in requestModel.Columns.GetFilteredColumns())
{
    string query = column.Data + ".Contains(\"" + column.Search.Value + "\")";
    myFilteredData = myFilteredData.Where(query).ToList();
}

//Set your dataset on the same order as requested from client-side either directly on your SQL code or easily
//into any type or enumeration.
bool isSorted = false;
foreach (var column in requestModel.Columns.GetSortedColumns())
{
    if (!isSorted)
    {
        // Apply first sort.
        if (column.SortDirection == Column.OrderDirection.Ascendant)
            myFilteredData = myFilteredData.OrderBy(column.Data).ToList();
        else
            myFilteredData = myFilteredData.OrderBy(column.Data + " descending").ToList();

        isSorted = true;
    }
    else
    {
        if (column.SortDirection == Column.OrderDirection.Ascendant)
            myFilteredData = myFilteredData.OrderBy(column.Data).ToList();
        else
            myFilteredData = myFilteredData.OrderBy(column.Data + " descending").ToList();
    }
}

var paged = myFilteredData.Skip(requestModel.Start).Take(requestModel.Length);
return Json(new DataTablesResponse(requestModel.Draw, paged, myFilteredData.Count(), myOriginalDataSet.Count()), JsonRequestBehavior.AllowGet);
}

谢谢。 Vegeta_77

我有它,我的朋友们!!!!!!!!!!!!!!!!!!!!!!!!! 非常不错:-)

解决方法如下:

$(document).ready(function() {
    $('#example').dataTable( {
        "processing": true,
        "serverSide": true,
        "ajax": {
            "url": "scripts/post.php",
            "type": "POST"
        },
        "columns": [
            { "data": "first_name" },
            { "data": "last_name" },
            { "data": "position" },
            { "data": "office" },
            { "data": "start_date" },
            { "data": "salary" }
        ]
    } );
} );

我刚刚编辑了 "ajax"。当您使用 "type" "POST" 时,它会起作用。

非常感谢。

你好 Vegeta_77