[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [9599] controller: serverbased pagination
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [9599] controller: serverbased pagination |
Date: |
Fri, 15 Jun 2012 10:42:20 +0000 |
Revision: 9599
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=9599
Author: sigurdne
Date: 2012-06-15 10:42:19 +0000 (Fri, 15 Jun 2012)
Log Message:
-----------
controller: serverbased pagination
Modified Paths:
--------------
trunk/controller/inc/class.uicontrol_location.inc.php
trunk/controller/js/controller/ajax_control_to_component.js
trunk/controller/js/yahoo/register_control_to_component2.js
trunk/controller/templates/base/control_location/register_control_to_component.xsl
Removed Paths:
-------------
trunk/controller/js/yahoo/register_control_to_component.js
Modified: trunk/controller/inc/class.uicontrol_location.inc.php
===================================================================
--- trunk/controller/inc/class.uicontrol_location.inc.php 2012-06-14
18:15:26 UTC (rev 9598)
+++ trunk/controller/inc/class.uicontrol_location.inc.php 2012-06-15
10:42:19 UTC (rev 9599)
@@ -825,7 +825,8 @@
$results['startIndex'] = $this->start;
$results['sort'] = 'location_code';
$results['dir'] = "ASC";
- $results['pageSize'] = 10;
+ $results['pageSize'] =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+ $results['activePage'] = floor($this->start /
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs']) + 1;
$results['records'] = $values;
return $results;
Modified: trunk/controller/js/controller/ajax_control_to_component.js
===================================================================
--- trunk/controller/js/controller/ajax_control_to_component.js 2012-06-14
18:15:26 UTC (rev 9598)
+++ trunk/controller/js/controller/ajax_control_to_component.js 2012-06-15
10:42:19 UTC (rev 9599)
@@ -75,7 +75,6 @@
});
$("#cat_id").html( htmlString );
- // update_component_table();
}
else
{
@@ -163,6 +162,8 @@
}
}
});
+
+ update_component_table();
});
@@ -199,6 +200,7 @@
}
});
+ update_component_table();
});
$("#loc1").change(function ()
@@ -232,6 +234,8 @@
}
});
+ update_component_table();
+
});
@@ -279,17 +283,7 @@
{
$(submitBnt).val("Lagret");
- var oArgs = {
-
menuaction:'controller.uicontrol_location.query2',
- entity_id:$("#entity_id").val(),
- cat_id:$("#cat_id").val(),
-
district_id:$("#district_id").val(),
-
part_of_town_id:$("#part_of_town_id").val(),
- location_code:$("#loc1").val(),
-
control_id:$("#control_id").val()
- };
-
-
execute_async(myDataTable_0,oArgs);
+
YAHOO.PORTICO.update_datatable();
}
else
{
@@ -400,9 +394,8 @@
if( data != null)
{
myColumnDefs = [];
- myColumnDefs.push(data);
-// update_component_table_def();
- update_component_table2();
+ myColumnDefs.push(data);
+ init_component_table();
}
else
{
@@ -414,7 +407,7 @@
}
-function update_component_table2()
+function init_component_table()
{
var oArgs = {
menuaction:'controller.uicontrol_location.query2',
@@ -427,30 +420,28 @@
};
var requestUrl = phpGWLink('index.php', oArgs, true);
- YAHOO.example.DynamicData(myColumnDefs[0],requestUrl);
+ YAHOO.PORTICO.init_datatable(myColumnDefs[0],requestUrl);
}
-function update_component_table_def()
-{
- pager = YAHOO.util.Dom.get("paging_0");
- div = YAHOO.util.Dom.get("datatable-container_0");
- this.init_datatable(datatable[0],div,pager,myColumnDefs[0],0);
-}
-
function update_component_table()
{
- var oArgs = {
- menuaction:'controller.uicontrol_location.query2',
- entity_id:$("#entity_id").val(),
- cat_id:$("#cat_id").val(),
- district_id:$("#district_id").val(),
- part_of_town_id:$("#part_of_town_id").val(),
- location_code:$("#loc1").val(),
- control_id:$("#control_id").val()
- };
+ if($("#cat_id").val() != null)
+ {
+ var oArgs = {
+ menuaction:'controller.uicontrol_location.query2',
+ entity_id:$("#entity_id").val(),
+ cat_id:$("#cat_id").val(),
+ district_id:$("#district_id").val(),
+ part_of_town_id:$("#part_of_town_id").val(),
+ location_code:$("#loc1").val() != null ?
$("#loc1").val():'',
+ control_id:$("#control_id").val() != null ?
$("#control_id").val():''
+ };
- execute_async(myDataTable_0, oArgs);
+ var requestUrl = phpGWLink('index.php', oArgs, true);
+
+ YAHOO.PORTICO.update_datatable(requestUrl);
+ }
// $("#receipt").html('');
}
Deleted: trunk/controller/js/yahoo/register_control_to_component.js
===================================================================
--- trunk/controller/js/yahoo/register_control_to_component.js 2012-06-14
18:15:26 UTC (rev 9598)
+++ trunk/controller/js/yahoo/register_control_to_component.js 2012-06-15
10:42:19 UTC (rev 9599)
@@ -1,66 +0,0 @@
-var myPaginator_0, myDataTable_0
-
- this.myParticularRenderEvent = function()
- {
-
- }
-
-
-
- var FormatterRight = function(elCell, oRecord, oColumn, oData)
- {
- elCell.innerHTML = "<div align=\"right\">"+oData+"</div>";
- }
-
- var FormatterCenter = function(elCell, oRecord, oColumn, oData)
- {
- elCell.innerHTML = "<center>"+oData+"</center>";
- }
-
-
- function checkAll(myclass)
- {
- controls = YAHOO.util.Dom.getElementsByClassName(myclass);
-
- for(i=0;i<controls.length;i++)
- {
- if(!controls[i].disabled)
- {
-// if(myclass=="mychecks")
- {
- if(controls[i].checked)
- {
- controls[i].checked = false;
- }
- else
- {
- controls[i].checked = true;
- }
- }
- //for the rest, always id checked
-// else
-// {
-// controls[i].checked = true;
-// }
- }
- }
- }
-
-
/********************************************************************************/
-
-
-YAHOO.util.Event.addListener(window, "load", function()
-{
- loader = new YAHOO.util.YUILoader();
- loader.addModule({
- name: "anyone",
- type: "js",
- fullpath: property_js
- });
-
- loader.require("anyone");
- loader.insert();
-});
-
-
-
Modified: trunk/controller/js/yahoo/register_control_to_component2.js
===================================================================
--- trunk/controller/js/yahoo/register_control_to_component2.js 2012-06-14
18:15:26 UTC (rev 9598)
+++ trunk/controller/js/yahoo/register_control_to_component2.js 2012-06-15
10:42:19 UTC (rev 9599)
@@ -1,13 +1,96 @@
-YAHOO.example.DynamicData = function(myColumnDefs,requestUrl) {
+YAHOO.namespace ("PORTICO");
- // Custom parser
- var timestampToDate = function(oData) {
- // timestamp comes from server in seconds
- // JS needs it in milliseconds
- return new Date(oData*1000);
- };
+YAHOO.PORTICO.requestUrl = null;
+YAHOO.PORTICO.DataTable = null;
+YAHOO.PORTICO.Paginator = null;
+YAHOO.PORTICO.update_datatable = function(requestUrl) {
+
+ requestUrl = requestUrl ? requestUrl : YAHOO.PORTICO.requestUrl;
+
+ var callback =
+ {
+ success: function(o)
+ {
+/*
+ if(config_values.PanelLoading)
+ {
+ myLoading.hide();
+ }
+*/
+ values_ds = JSON.parse(o.responseText);
+
+ if(values_ds && values_ds['sessionExpired'] == true)
+ {
+ window.alert('sessionExpired - please log in');
+// lightboxlogin();//defined i
phpgwapi/templates/portico/js/base.js
+ }
+ else
+ {
+
+
YAHOO.PORTICO.Paginator.setRowsPerPage(values_ds.recordsReturned,true);
+
+ //delete values of datatable
+ YAHOO.PORTICO.DataTable.getRecordSet().reset();
+
+ //reset total records always to zero
+ YAHOO.PORTICO.Paginator.setTotalRecords(0,true);
+/*
+ //change PaginatorŽs configuration.
+ if(path_values.allrows == 1 )
+ {
+
YAHOO.PORTICO.Paginator.set("rowsPerPage",values_ds.totalRecords)
+ }
+*/
+ //obtain records of the last DS and add to
datatable
+ var record = values_ds.records;
+ var newTotalRecords = values_ds.totalRecords;
+
+ if(record.length)
+ {
+ YAHOO.PORTICO.DataTable.addRows(record);
+ }
+ else
+ {
+ YAHOO.PORTICO.DataTable.render();
+ }
+
+ //update paginator with news values
+
YAHOO.PORTICO.Paginator.setTotalRecords(newTotalRecords,true);
+
+ //update globals variables for pagination
+ myrowsPerPage = values_ds.recordsReturned;
+ mytotalRows = values_ds.totalRecords;
+
+ //update combo box pagination
+//
YAHOO.PORTICO.Paginator.set('rowsPerPageOptions',[myrowsPerPage,mytotalRows]);
+
+
YAHOO.PORTICO.Paginator.setPage(values_ds.activePage,true); //true no fuerza un
recarge solo cambia el paginator
+
+ //update "sortedBy" values
+
+ (values_ds.dir == "asc")? dir_ds =
YAHOO.widget.DataTable.CLASS_ASC : dir_ds = YAHOO.widget.DataTable.CLASS_DESC;
+
YAHOO.PORTICO.DataTable.set("sortedBy",{key:values_ds.sort,dir:dir_ds});
+ }
+ },
+ failure: function(o) {window.alert('Server or your connection
is dead.')},
+ timeout: 10000,
+ cache: false
+ }
+
+ try
+ {
+ YAHOO.util.Connect.asyncRequest('POST',requestUrl,callback);
+ }
+ catch(e_async)
+ {
+ alert(e_async.message);
+ }
+};
+
+YAHOO.PORTICO.init_datatable = function(myColumnDefs,requestUrl) {
+
fields = new Array();
for(i=0; i < myColumnDefs.length;i++)
{
@@ -34,51 +117,63 @@
var sort = (oState.sortedBy) ? oState.sortedBy.key : "id";
var dir = (oState.sortedBy && oState.sortedBy.dir ===
YAHOO.widget.DataTable.CLASS_DESC) ? "desc" : "asc";
var startIndex = (oState.pagination) ? oState.pagination.recordOffset
: 0;
- var results = (oState.pagination) ? oState.pagination.rowsPerPage : 25;
+ var results = (oState.pagination) ? oState.pagination.rowsPerPage : 10;
// Build custom request
return "&order=" + sort +
"&sort=" + dir +
"&start=" + startIndex +
- "&results=" + (startIndex + results);
+ "&results=" + results;
};
+ myinitialPage = 1 //+ startIndex/myrowsPerPage;
+
+ myPaginatorConfig = {
+ containers
: ['paging'],
+// totalRecords :
mytotalRows,
+ initialPage :
myinitialPage,
+ rowsPerPage: 10,
+// alwaysVisible: true,
+// rowsPerPageOptions: [5, 10, 25,
50, 100, 200],
+// firstPageLinkLabel: "<<
first",
+// previousPageLinkLabel: "<
previous",
+// nextPageLinkLabel: "next >",
+// lastPageLinkLabel: "last
>>",
+ template
: "{CurrentPageReport}<br/> {FirstPageLink} {PreviousPageLink} {PageLinks}
{NextPageLink} {LastPageLink}",
+ pageReportTemplate :
"shows_from {startRecord} to {endRecord} of_total {totalRecords}."
+ }
+ myPaginator = new YAHOO.widget.Paginator(myPaginatorConfig);
+
+ YAHOO.PORTICO.Paginator = myPaginator
+
// DataTable configuration
var myConfigs = {
generateRequest: generateRequest,
initialRequest: generateRequest(), // Initial request for first page
of data
dynamicData: true, // Enables dynamic server-driven data
sortedBy : {key:"id", dir:YAHOO.widget.DataTable.CLASS_ASC}, // Sets
UI initial sort arrow
- paginator: new YAHOO.widget.Paginator({
- rowsPerPage: 10,
-// alwaysVisible: true,
-// rowsPerPageOptions: [5, 10, 25, 50, 100, 200],
-// firstPageLinkLabel: "<< first",
-// previousPageLinkLabel: "< previous",
-// nextPageLinkLabel: "next >",
-// lastPageLinkLabel: "last >>",
- template :
"{CurrentPageReport}<br/> {FirstPageLink} {PreviousPageLink} {PageLinks}
{NextPageLink} {LastPageLink}",
- pageReportTemplate : "shows_from
{startRecord} to {endRecord} of_total {totalRecords}."
-
- }) // Enables pagination
+ paginator: myPaginator // Enables pagination
};
// DataTable instance
var myDataTable = new YAHOO.widget.DataTable("dynamicdata", myColumnDefs,
myDataSource, myConfigs);
// Update totalRecords on the fly with values from server
myDataTable.doBeforeLoadData = function(oRequest, oResponse, oPayload) {
+ YAHOO.PORTICO.requestUrl = requestUrl + oRequest;
oPayload.totalRecords = oResponse.meta.totalRecords;
oPayload.pagination.recordOffset = oResponse.meta.startIndex;
return oPayload;
};
+ YAHOO.PORTICO.DataTable = myDataTable;
+
return {
ds: myDataSource,
dt: myDataTable
};
};
-//YAHOO.util.Event.onDOMReady( YAHOO.example.DynamicData );
+//YAHOO.util.Event.onDOMReady( YAHOO.PORTICO.init_datatable );
var FormatterRight = function(elCell, oRecord, oColumn, oData)
{
@@ -112,4 +207,3 @@
}
}
-
Modified:
trunk/controller/templates/base/control_location/register_control_to_component.xsl
===================================================================
---
trunk/controller/templates/base/control_location/register_control_to_component.xsl
2012-06-14 18:15:26 UTC (rev 9598)
+++
trunk/controller/templates/base/control_location/register_control_to_component.xsl
2012-06-15 10:42:19 UTC (rev 9599)
@@ -184,6 +184,7 @@
<xsl:template match="datatable" xmlns:php="http://php.net/xsl">
+ <div id="paging"></div>
<div id="dynamicdata"></div>
<xsl:call-template name="datasource-definition" />
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [9599] controller: serverbased pagination,
Sigurd Nes <=