DataTables::create(array(
"name" => "table1",
"dataStore" => isset($this->params["subject"]) ? $this->dataStore("Strategy_list_Subject") : [],
// "data"=>isset($this->params["customerNumber"])?null:array(),
//"plugins" => ["Buttons", "FixedColumns", "FixedHeader", "KeyTable", "Responsive", "RowReorder", "Scroller", "SearchPanes"],
"options" => array(
//"dom" => 'Blfrtip',
"select"=>true,
"searching" => true,
"fixedHeader"=>true,
'columnDefs' => array(
array(
'type' => 'customType',
'targets' => 9,
),
array(
'type' => 'customType',
'targets' => 10,
),
array(
'type' => 'customType',
'targets' => 11,
),
array(
'type' => 'customType',
'targets' => 12,
),
array(
'type' => 'customType',
'targets' => 13,
),
array(
'type' => 'customType',
'targets' => 14,
),
),
/*'order' => array(
array(9, 'asc'),
array(10, 'asc'),
array(11, 'asc'),
array(12, 'asc'),
array(13, 'asc'),
array(14, 'asc'),
),*/
),
"showFooter" => true,
"columns" => array(
"subjectnm" => array(
"label" => "Subject Name",
),
"user2122" => array(
"label" => "2021-22 Total User Schools",
"type" => "num-fmt",
"footer"=>"sum",
"footerText"=>"<b>@value</b>",
"formatValue"=>function($value,$row)
{
return preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $value );
}
),
"uservol2122" => array(
"label" => "2021-22 Total User Schools Volume",
"type" => "num-fmt",
"footer"=>"sum",
"footerText"=>"<b>@value</b>",
"formatValue"=>function($value,$row)
{
return preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $value );
}
),
"plnsch" => array(
"label" => "2022-23 Total Schools Planned",
"type" => "num-fmt",
"footer"=>"sum",
"footerText"=>"<b>@value</b>",
"formatValue"=>function($value,$row)
{
return preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $value );
}
),
"plnschvol" => array(
"label" => "2022-23 Total Schools Planned Volume",
"type" => "num-fmt",
"footer"=>"sum",
"footerText"=>"<b>@value</b>",
"formatValue"=>function($value,$row)
{
return preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $value );
}
),
"retainpln" => array(
"label" => "2022-23 Total Retain Schools Planned",
"type" => "num-fmt",
"footer"=>"sum",
"footerText"=>"<b>@value</b>",
"formatValue"=>function($value,$row)
{
return preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $value );
}
),
"retainplnvol" => array(
"label" => "2022-23 Total Retain Schools Planned Volume",
"type" => "num-fmt",
"footer"=>"sum",
"footerText"=>"<b>@value</b>",
"formatValue"=>function($value,$row)
{
return preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $value );
}
),
"newpln" => array(
"label" => "2022-23 Total New Schools Planned",
"type" => "num-fmt",
"footer"=>"sum",
"footerText"=>"<b>@value</b>",
"formatValue"=>function($value,$row)
{
return preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $value );
}
),
"newplnvol" => array(
"label" => "2022-23 Total New Schools Planned Volume",
"type" => "num-fmt",
"footer"=>"sum",
"footerText"=>"<b>@value</b>",
"formatValue"=>function($value,$row)
{
return preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $value );
}
),
"user2223" => array(
"label" => "2022-23 Total User Schools",
"type" => "num-fmt",
"footer"=>"sum",
"footerText"=>"<b>@value</b>",
"formatValue"=>function($value,$row, $cKey)
{
if ($cKey === 'user2223')
{
if ($row["user2122"] == $value) {
$a = 100;
$css = indicators3($val = $a, $indicator_array = array(0, 99, 100), $indicator_rating = "normal");
return "<div class='" . $css . "'>" . preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $value ) . "</div>";
} elseif ($row["user2122"] > $value) {
$a = 50;
$css = indicators3($val = $a, $indicator_array = array(0, 99, 100), $indicator_rating = "normal");
return "<div class='" . $css . "'>" . preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $value ) . "</div>";
}
elseif ($row["user2122"] < $value){
$a = 101;
$css = indicators3($val = $a, $indicator_array = array(0, 99, 100), $indicator_rating = "normal");
return "<div class='" . $css . "'>" . preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $value ) . "</div>";
}
else{
return preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $value );
}
}
else{
return preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $value );
}
},
),
"uservol2223" => array(
"label" => "2022-23 Total User Schools Volume",
"type" => "num-fmt",
"footer"=>"sum",
"footerText"=>"<b>@value</b>",
"formatValue"=>function($value,$row, $cKey)
{
if ($cKey === 'uservol2223')
{
if ($row["uservol2122"] == $value) {
$a = 100;
$css = indicators3($val = $a, $indicator_array = array(0, 99, 100), $indicator_rating = "normal");
return "<div class='" . $css . "'>" . preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $value ) . "</div>";
} elseif ($row["uservol2122"] > $value) {
$a = 50;
$css = indicators3($val = $a, $indicator_array = array(0, 99, 100), $indicator_rating = "normal");
return "<div class='" . $css . "'>" . preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $value ) . "</div>";
}
elseif ($row["uservol2122"] < $value){
$a = 101;
$css = indicators3($val = $a, $indicator_array = array(0, 99, 100), $indicator_rating = "normal");
return "<div class='" . $css . "'>" . preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $value ) . "</div>";
}
else{
return preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $value );
}
}
else{
return preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $value );
}
},
),
"retainuser" => array(
"label" => "2022-23 Total Retain Schools",
"type" => "num-fmt",
"footer"=>"sum",
"footerText"=>"<b>@value</b>",
"formatValue"=>function($value,$row, $cKey)
{
if ($cKey === 'retainuser')
{
if ($row["retainpln"] == $value) {
$a = 100;
$css = indicators3($val = $a, $indicator_array = array(0, 99, 100), $indicator_rating = "normal");
return "<div class='" . $css . "'>" . preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $value ) . "</div>";
} elseif ($row["retainpln"] > $value) {
$a = 50;
$css = indicators3($val = $a, $indicator_array = array(0, 99, 100), $indicator_rating = "normal");
return "<div class='" . $css . "'>" . preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $value ) . "</div>";
}
elseif ($row["retainpln"] < $value){
$a = 101;
$css = indicators3($val = $a, $indicator_array = array(0, 99, 100), $indicator_rating = "normal");
return "<div class='" . $css . "'>" . preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $value ) . "</div>";
}
else{
return preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $value );
}
}
else{
return preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $value );
}
},
),
"retainuservol" => array(
"label" => "2022-23 Total Retain Schools Volume",
"type" => "num-fmt",
"footer"=>"sum",
"footerText"=>"<b>@value</b>",
"formatValue"=>function($value,$row, $cKey)
{
if ($cKey === 'retainuservol')
{
if ($row["retainplnvol"] == $value) {
$a = 100;
$css = indicators3($val = $a, $indicator_array = array(0, 99, 100), $indicator_rating = "normal");
return "<div class='" . $css . "'>" . preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $value ) . "</div>";
} elseif ($row["retainplnvol"] > $value) {
$a = 50;
$css = indicators3($val = $a, $indicator_array = array(0, 99, 100), $indicator_rating = "normal");
return "<div class='" . $css . "'>" . preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $value ) . "</div>";
}
elseif ($row["retainplnvol"] < $value){
$a = 101;
$css = indicators3($val = $a, $indicator_array = array(0, 99, 100), $indicator_rating = "normal");
return "<div class='" . $css . "'>" . preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $value ) . "</div>";
}
else{
return preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $value );
}
}
else{
return preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $value );
}
},
),
"newuser" => array(
"label" => "2022-23 Total New Schools",
"type" => "num-fmt",
"footer"=>"sum",
"footerText"=>"<b>@value</b>",
"formatValue"=>function($value,$row, $cKey)
{
if ($cKey === 'newuser')
{
if ($row["newpln"] == $value) {
$a = 100;
$css = indicators3($val = $a, $indicator_array = array(0, 99, 100), $indicator_rating = "normal");
return "<div class='" . $css . "'>" . preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $value ) . "</div>";
} elseif ($row["newpln"] > $value) {
$a = 50;
$css = indicators3($val = $a, $indicator_array = array(0, 99, 100), $indicator_rating = "normal");
return "<div class='" . $css . "'>" . preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $value ) . "</div>";
}
elseif ($row["newpln"] < $value){
$a = 101;
$css = indicators3($val = $a, $indicator_array = array(0, 99, 100), $indicator_rating = "normal");
return "<div class='" . $css . "'>" . preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $value ) . "</div>";
}
else{
return preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $value );
}
}
else{
return preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $value );
}
},
),
"newuservol" => array(
"label" => "2022-23 Total New Schools Volume",
"type" => "num-fmt",
"footer"=>"sum",
"footerText"=>"<b>@value</b>",
"formatValue"=>function($value,$row, $cKey)
{
if ($cKey === 'newuservol')
{
if ($row["newplnvol"] == $value) {
$a = 100;
$css = indicators3($val = $a, $indicator_array = array(0, 99, 100), $indicator_rating = "normal");
return "<div class='" . $css . "'>" . preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $value ) . "</div>";
} elseif ($row["newplnvol"] > $value) {
$a = 50;
$css = indicators3($val = $a, $indicator_array = array(0, 99, 100), $indicator_rating = "normal");
return "<div class='" . $css . "'>" . preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $value ) . "</div>";
}
elseif ($row["newplnvol"] < $value){
$a = 101;
$css = indicators3($val = $a, $indicator_array = array(0, 99, 100), $indicator_rating = "normal");
return "<div class='" . $css . "'>" . preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $value ) . "</div>";
}
else{
return preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $value );
}
}
else{
return preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $value );
}
},
),
"lostuser" => array(
"label" => "Total Lost Schools",
"type" => "num-fmt",
"footer"=>"sum",
"footerText"=>"<b>@value</b>",
),
"lostuservol" => array(
"label" => "Total Lost Schools Volume",
"type" => "num-fmt",
"footer"=>"sum",
"footerText"=>"<b>@value</b>",
"formatValue"=>function($value,$row)
{
return preg_replace("/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/i", "$1,", $value );
}
),
),
"cssClass" => array(
// "table" => "table table-bordered table-striped table-hover cssText is-datatable",
"table" => "table table-bordered table-hover",
"th"=>"cssHeader",
"tr"=>"cssItem",
"tf"=>"cssIFooter",
"td"=>function($row,$colName)
{
if ($colName=="subjectnm" or $colName=="seriesnm" or $colName=="execcode" or $colName=="execname")
{
return "cssTd";
}
else if ($colName=="user2122" or $colName=="uservol2122" or $colName=="user2223" or $colName=="retainuser" or $colName=="retainuservol" or
$colName=="newuser" or $colName=="newuservol" )
{
return "cssTdw";
}
else
{
return "cssTdw1";
}
},
),
));
in columndef, for the type: customtype it is sorting based on indicator/color i have given, I need sorting based on the number present on that column....its not happening like remaining columns, Please help me in this regard.
In the above images you can clearly see the sorting/filtering is happening to color not for the numbers....
Please check once and i have implemented the above code only