[Weberp-svn] SF.net SVN: weberp:[9454] trunk
Brought to you by:
sotandeka,
tim_schofield
From: <tim...@us...> - 2012-07-28 18:11:49
|
Revision: 9454 http://weberp.svn.sourceforge.net/weberp/?rev=9454&view=rev Author: tim_schofield Date: 2012-07-28 18:11:43 +0000 (Sat, 28 Jul 2012) Log Message: ----------- New table sorting functionality Modified Paths: -------------- trunk/AccountGroups.php trunk/javascripts/FormFunctions.js Modified: trunk/AccountGroups.php =================================================================== --- trunk/AccountGroups.php 2012-07-28 18:11:31 UTC (rev 9453) +++ trunk/AccountGroups.php 2012-07-28 18:11:43 UTC (rev 9454) @@ -242,10 +242,10 @@ </tr> <tr> <th class="SortableColumn" onclick="SortSelect(this)">' . _('Group Name') . '</th> - <th>' . _('Section') . '</th> - <th>' . _('Sequence In TB') . '</th> - <th>' . _('Profit and Loss') . '</th> - <th>' . _('Parent Group') . '</th> + <th class="SortableColumn" onclick="SortSelect(this)">' . _('Section') . '</th> + <th class="SortableColumn" onclick="SortSelect(this)">' . _('Sequence In TB') . '</th> + <th class="SortableColumn" onclick="SortSelect(this)">' . _('Profit and Loss') . '</th> + <th class="SortableColumn" onclick="SortSelect(this)">' . _('Parent Group') . '</th> </tr>'; $k=0; //row colour counter @@ -290,7 +290,7 @@ if (!isset($_GET['delete'])) { echo '<td class="background_td" width="50%">'; - echo '<form method="post" id="AccountGroups" onsubmit="return SubmitForm(this)" action="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '">'; + echo '<form method="post" id="AccountGroups" onsubmit="return SubmitForm(this, \'\')" action="' . basename(htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8')) . '">'; echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; if (isset($_GET['SelectedAccountGroup'])) { @@ -443,4 +443,4 @@ } //end if record deleted no point displaying form to add record include('includes/footer.inc'); -?> \ No newline at end of file +?> Modified: trunk/javascripts/FormFunctions.js =================================================================== --- trunk/javascripts/FormFunctions.js 2012-07-28 18:11:31 UTC (rev 9453) +++ trunk/javascripts/FormFunctions.js 2012-07-28 18:11:43 UTC (rev 9454) @@ -11,8 +11,8 @@ return false; } -function MakePageInVisible() { - document.getElementById("contents").style.display='none'; +function MakePageInVisible(w) { + w.style.display='none'; return false; } @@ -32,34 +32,59 @@ function SortSelect(selElem) { var tmpArray = new Array(); + columnText=selElem.innerHTML; parentElem=selElem.parentNode; table=parentElem.parentNode; - for (var i = 0, row; row = table.rows[i]; i++) { - //iterate through rows - //rows would be accessed using the "row" variable assigned in the for loop + row = table.rows[1]; + for (var j = 0, col; col = row.cells[j]; j++) { + if (row.cells[j].innerHTML==columnText) { + columnNumber=j; + s=getComputedStyle(row.cells[j]); + if (s.cursor=="s-resize") { + row.cells[j].style.cursor="n-resize"; + direction="a"; + } else { + row.cells[j].style.cursor="s-resize"; + direction="d"; + } + } + } + for (var i = 2, row; row = table.rows[i]; i++) { + var rowArray = new Array(); for (var j = 0, col; col = row.cells[j]; j++) { - //iterate through columns - //columns would be accessed using the "col" variable assigned in the for loop if (row.cells[j].tagName == 'TD' ) { - tmpArray[i,j]=row.cells[j].innerHTML; - alert(tmpArray[i,j]); + rowArray[j]=row.cells[j].innerHTML; + columnClass=row.cells[columnNumber].className; } } + tmpArray[i]=rowArray; } - for (var i=0;i<selElem.options.length;i++) { - tmpArray[i] = new Array(); - tmpArray[i][0] = parseInt(selElem.options[i].text); - tmpArray[i][1] = parseInt(selElem.options[i].value); + tmpArray.sort( + function(a,b) { + if (direction=="a") { + if (columnClass=="number") { + return a[columnNumber]-b[columnNumber]; + } else { + return a[columnNumber].localeCompare(b[columnNumber]) + } + } else { + if (columnClass=="number") { + return b[columnNumber]-a[columnNumber]; + } else { + return b[columnNumber].localeCompare(a[columnNumber]) + } + } + } + ); + for (var i = 0, row; row = table.rows[i+2]; i++) { + var rowArray = new Array(); + rowArray=tmpArray[i]; + for (var j = 0, col; col = row.cells[j]; j++) { + if (row.cells[j].tagName == 'TD' ) { + row.cells[j].innerHTML=rowArray[j]; + } + } } - tmpArray.sort(function(a,b){return b-a}); - tmpArray.reverse(); - while (selElem.options.length > 0) { - selElem.options[0] = null; - } - for (var i=0;i<tmpArray.length;i++) { - var op = new Option(tmpArray[i][0], tmpArray[i][1]); - selElem.options[i] = op; - } return; } @@ -172,8 +197,8 @@ return false; } -function OnSelectClick(RadioButton) { - document.getElementById("ChooseCustomer").value=RadioButton.value; +function OnSelectClick(RadioButton, ButtonID) { + ButtonID.value=RadioButton.value; return false; } @@ -198,7 +223,7 @@ function CloseSubWindow() { document.getElementById("Mask").setAttribute("class", "unmask"); - document.getElementById("contents").innerHTML=""; +// document.getElementById("contents").innerHTML=""; document.getElementById("SubWindow").innerHTML="<div id=\"contents\"></div>"; document.getElementById("SubWindow").removeAttribute("class", "inputbox"); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |