Question on sorting and a filtration

Question on sorting and a filtration

stimkastimka Posts: 2Questions: 0Answers: 0
edited April 2013 in General
Hello from Russia! Problem that all data are output by means of PHP and SQl. At present sorting works, but sorting in DESC and as how many time tried to make sorting of date of dd/mm/yyyy doesn't work, it turned out nothing. I found the decision where give a decision example for PHP, but it not so suits me :(

see my code

[code] <!-- datatable -->

<!-- additional sorting for datatables -->




$(document).ready(function(){
$("#myTable").dataTable({
"oLanguage": {
"sUrl": "datatables/language/ru_RU.txt"
},
"aaSorting": [[ 1, "desc" ]],
"iDefaultSortIndex": 1,
"iDisplayLength": 25,
"sDefaultSortDirection": "asc"
"aoColumns": [
{"bSortable": true},
{"bSortable": false},
null,
{"sType": "date-euro"},
null
]
} );
} );






Статус
Исполнить до
Наименование эксплуатационной организации
Дата составл.
Дата исполнения.
Ответственный.
Ссылка.
Действия



<?foreach($main_news as $item):?>

<?
/// МОИ СТАТУСЫ

$status1 = "onebit_09.png";
$status2 = "onebit_07.png";
$status3 = "onebit_06.png";
$status4 = "onebit_10.png";
$result = mysql_query("SELECT NaimenovanijeObjekta FROM objekts, news WHERE news.title = objekts.KodObjekta and news.id = '".$item['id']."'");
$myrow = mysql_fetch_array($result);

?>


<?=$item['id'];?>

<?
$d = $item['datavvoda'];
$d = date("d.m.Y", strtotime($d));
$date2 = date("d.m.Y");


$arr1 = explode(" ", $d);
$arr2 = explode(" ", $date2);
$arrdate1 = explode(".", $arr1[0]);
$arrdate2 = explode(".", $arr2[0]);
$arrtime1 = explode(":", $arr1[1]);
$arrtime2 = explode(":", $arr2[1]);
$timestamp2 = (mktime($arrtime2[0], $arrtime2[1], 0, $arrdate2[1], $arrdate2[0], $arrdate2[2]));
$timestamp1 = (mktime($arrtime1[0], $arrtime1[1], 0, $arrdate1[1], $arrdate1[0], $arrdate1[2]));

if($timestamp1 < $timestamp2)
{
if(empty($item['otvet']))
{
echo <<
<? if ($_SESSION['status'] > '1')
{
echo <<
<?
$d2 = $item['data'];
$d2 = date("d.m.Y", strtotime($d2));

echo $d2;
?>
<?
$d6 = $item['dataisp'];
$d6 = date("d.m.Y", strtotime($d6));

?><? if ($d6 == '30.11.-0001')
{
echo "нет информации";

}
else
{
echo $d6;
}
?>
<? if (empty($item['otvetstv']))
{
echo "нет информации";

}
else
{
echo $item['otvetstv'];
}
?>
просмотр
<? if ($_SESSION['status'] > '1')
{
echo <<

[/code]

Probably it turns out nothing, as data not through JSON. I will be glad to any help. Excuse for my English =)

Replies

  • allanallan Posts: 63,205Questions: 1Answers: 10,415 Site admin
    Please link to a test page: http://datatables.net/extras/tabletools/plug-ins .

    Very likely DataTables isn't detecting dd/mm/yyyy as a valid date column, since it uses the browser's Date.parse(). However, without a test case, I can't know and I'm just guessing.

    I'd suggest you probably want to use a sorting plug-in: http://datatables.net/plug-ins/sorting

    Allan
This discussion has been closed.