[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 239/323: Manage_Table : add sort on header co
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 239/323: Manage_Table : add sort on header column |
Date: |
Wed, 14 Mar 2018 17:38:58 -0400 (EDT) |
sparkyx pushed a commit to branch master
in repository noalyss.
commit e66033d9b5512693b5d442c87367d3c54a7220b1
Author: Dany De Bontridder <address@hidden>
Date: Fri Feb 23 20:38:25 2018 +0100
Manage_Table : add sort on header column
---
include/lib/manage_table_sql.class.php | 45 +++++++++++++++++++++++++++-------
scenario/test_manage_table_sql.php | 4 +--
2 files changed, 38 insertions(+), 11 deletions(-)
diff --git a/include/lib/manage_table_sql.class.php
b/include/lib/manage_table_sql.class.php
index 24daa4b..2d1b9f1 100644
--- a/include/lib/manage_table_sql.class.php
+++ b/include/lib/manage_table_sql.class.php
@@ -58,6 +58,7 @@
@endcode
* @see ManageTable.js
* @see ajax_accounting.php
+ * @see sorttable.js
*
*/
@@ -78,7 +79,7 @@ class Manage_Table_SQL
protected $aerror; //!< Array containing the error of the input data
protected $col_sort; //!< when inserting, it is the column to sort,-1 to
disable it and append only
protected $a_info; //!< Array with the infotip
-
+ protected $sort_column; //!< javascript sort , if empty there is no js sort
const UPDATABLE=1;
const VISIBLE=2;
@@ -118,6 +119,8 @@ class Manage_Table_SQL
$this->icon_mod="right";
$this->icon_del="right";
$this->col_sort=0;
+ // By default no js sort
+ $this->sort_column="";
}
/**
* send the XML headers for the ajax call
@@ -626,7 +629,14 @@ function check()
}
}
echo _('Cherche')." ".HtmlInput::filter_table("tb".$this->object_name,
$result, 1);
- printf('<table class="result" id="tb%s">', $this->object_name);
+
+ // Set a sort on a column if sort_column is not empty
+ if ( $this->sort_column =="")
+ {
+ printf('<table class="result" id="tb%s">', $this->object_name);
+ } else {
+ printf('<table class="result sortable" id="tb%s">',
$this->object_name);
+ }
for ($i=0; $i<$nb; $i++)
{
if ($i==0)
@@ -659,31 +669,48 @@ function check()
if ($this->can_update_row() && $this->icon_mod=="left")
{
- echo th(" ", 'style="width:40px"');
+ echo th(" ", 'style="width:40px" class="sorttable_nosort"');
}
if ($this->can_delete_row() && $this->icon_del=="left")
{
- echo th(" ", 'style="width:40px"');
+ echo th(" ", 'style="width:40px" class="sorttable_nosort"');
}
for ($i=0; $i<$nb; $i++)
{
$key=$this->a_order[$i];
-
+ $sorted="";
+ if ( $key == $this->sort_column) {
+ $sorted=' class="sorttable_sorted"';
+ }
if ($this->get_property_visible($key)==true)
- echo th("","",$this->a_label_displaid[$key]);
+ echo th("",$sorted,$this->a_label_displaid[$key]);
}
if ($this->can_update_row() && $this->icon_mod=="right")
{
- echo th(" ", 'style="width:40px"');
+ echo th(" ", 'style="width:40px" class="sorttable_nosort"');
}
if ($this->can_delete_row() && $this->icon_del=="right")
{
- echo th(" ", 'style="width:40px"');
+ echo th(" ", 'style="width:40px" class="sorttable_nosort" ');
}
echo "</tr>";
}
-
+ /**
+ * set the column to sort by default
+ */
+ function set_sort_column($p_col)
+ {
+ $this->sort_column=$p_col;
+ }
+ /**
+ * return the column to sort
+ */
+ function get_sort_column()
+ {
+ return $this->sort_column;
+ }
+
/**
* @brief set the id value of a data row and load from the db
*/
diff --git a/scenario/test_manage_table_sql.php
b/scenario/test_manage_table_sql.php
index 6f813a7..b342606 100644
--- a/scenario/test_manage_table_sql.php
+++ b/scenario/test_manage_table_sql.php
@@ -51,7 +51,7 @@ $manage_table->set_col_label('pcm_val', "Poste");
$manage_table->set_col_label('parent_accounting', "Dépend");
$manage_table->set_col_label('pcm_lib', "Libellé");
$manage_table->set_col_label('pcm_type', "Type de
menu".Icon_Action::infobulle(33));
-
+$manage_table->set_sort_column("pcm_lib");
// Change visible property
function test_visible_update(Manage_Table_SQL
$p_manage_table,$p_property,$p_visible,$p_update) {
global $g_failed,$g_succeed;
@@ -75,11 +75,11 @@ test_visible_update($manage_table, "parent_accounting",
FALSE, FALSE);
test_visible_update($manage_table, "parent_accounting", FALSE, TRUE);
test_visible_update($manage_table, "parent_accounting", TRUE, FALSE);
test_visible_update($manage_table, "parent_accounting", TRUE, TRUE);
-
echo "<h1>"."Icon MODIFY place"."</h1>";
echo "<h2>"." Mod left"."</h2>";
$manage_table->set_icon_mod("left");
$manage_table->display_table("where pcm_val::text >= '400' order by
pcm_val::text limit 10");
+return;
echo "<h2>"." Mod right"."</h2>";
$manage_table->set_icon_mod("right");
- [Noalyss-commit] [noalyss] 194/323: Remove user_local_pref, (continued)
- [Noalyss-commit] [noalyss] 194/323: Remove user_local_pref, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 276/323: cosmetic center the form & logo, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 268/323: Merge branch 'master' of ns3:/srv/git/noalyss, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 244/323: ajax_card : warning if there is no category of cards, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 267/323: TVA : fix when outside VEN or PURCHASE , the selecting box for VAT didn't work, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 275/323: CSS : Anchor go_up, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 240/323: Cosmétique, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 314/323: Merge Master, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 296/323: install plugin : cosmétique, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 289/323: task #0001548: BALANCE - décalage afficha résumé classes, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 239/323: Manage_Table : add sort on header column,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 298/323: Cosmetic, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 256/323: Tag : select list fixed, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 302/323: Bug #0001562: Achat mémoriser également 3 champs, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 273/323: CSS : table sortable no margin, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 313/323: CSS cosmetic : highlight, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 189/323: Hight password and default user, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 290/323: Bug #1549 : VERIFBIL empty card, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 292/323: Merge branch 'master' of ns3:/srv/git/noalyss, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 255/323: Tag : select list add a close button, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 286/323: CSS : selected menu, Dany De Bontridder, 2018/03/14