ManageTable colorize the row in alternate

This commit is contained in:
Dany De Bontridder 2017-01-25 23:11:11 +01:00
parent 426d5b549f
commit c680698c89
4 changed files with 40 additions and 0 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 745 B

After

Width:  |  Height:  |  Size: 607 B

Before After
Before After

View file

@ -178,6 +178,7 @@ var ManageTable = function (p_table_name)
smoke.alert("Changement impossible");
throw "error in save";
}
alternate_row("tb"+answer['ctl']);
remove_waiting_box();
$("dtr").hide();
} catch (e) {
@ -211,6 +212,7 @@ var ManageTable = function (p_table_name)
if (answer['status'] == 'OK') {
var x=answer['ctl_row'];
$(x).hide();
alternate_row("tb"+answer['ctl']);
}else {
smoke.alert("Effacement impossible");
}

View file

@ -2937,3 +2937,34 @@ window.onload=function ()
init_scroll();
sorttable.init
}
/**
* @brief Colorize the rows of the table
* @param string p_table id of the table
*/
function alternate_row(p_table)
{
var len = $(p_table).tBodies[0].rows.length;
var i = 0;
var localClass = "";
for (i = 1; i < len; i++) {
localClass = (i % 2 == 0) ? "even" : "odd";
if (localClass == "even" && $(p_table).tBodies[0].rows[i].hasClassName("odd"))
{
$(p_table).tBodies[0].rows[i].removeClassName("odd");
}
if (localClass == "even" && !$(p_table).tBodies[0].rows[i].hasClassName("even"))
{
$(p_table).tBodies[0].rows[i].addClassName("even");
}
if (localClass == "odd" && $(p_table).tBodies[0].rows[i].hasClassName("even"))
{
$(p_table).tBodies[0].rows[i].removeClassName("even");
}
if (localClass == "odd" && !$(p_table).tBodies[0].rows[i].hasClassName("odd"))
{
$(p_table).tBodies[0].rows[i].addClassName("odd");
}
}
}

View file

@ -423,6 +423,7 @@ class Manage_Table_SQL
sprintf("%s.input('-1','%s')", $this->object_name,
$this->object_name));
}
printf ('<script> alternate_row("tb%s");</script>', $this->object_name);
}
/**
@ -442,6 +443,12 @@ class Manage_Table_SQL
if ($this->get_property_visible($key)==true)
echo th($this->a_label_displaid[$key]);
}
if ($this->can_update_row()) {
echo td(_('Modifier'));
}
if ($this->can_delete_row()) {
echo td(_('Effacer'));
}
echo "</tr>";
}