Please look at my problem below:
I use in my MVC-Web-Applikation the jquery datatables. When i display only 8 columns, everything works fine. But with 1 more column, i g
I have it, my friends!!!!!!!!!!!!!!!!!!!!!!! Very NICE :-)
Here is the Solution:
$(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" }
]
} );
} );
I had just to edit the "ajax". When you use the "type" "POST", then it works.
Thank you very much.
Greetz Vegeta_77
Good morning. Here the 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>
The server side result is good, look:
http://ziehl-abegg.com/files/ServerSide.jpg
@Sippy. I don't understand our second question.
The names are all correct, look at the third picture/link. Here is the methode "List" from the controller:
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);
}
THX. Vegeta_77