fmsystem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fmsystem-commits] [10264] api: yui inline table


From: Sigurd Nes
Subject: [Fmsystem-commits] [10264] api: yui inline table
Date: Fri, 19 Oct 2012 06:25:09 +0000

Revision: 10264
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=10264
Author:   sigurdne
Date:     2012-10-19 06:25:05 +0000 (Fri, 19 Oct 2012)
Log Message:
-----------
api: yui inline table

Modified Paths:
--------------
    trunk/phpgwapi/js/yahoo/common.js

Modified: trunk/phpgwapi/js/yahoo/common.js
===================================================================
--- trunk/phpgwapi/js/yahoo/common.js   2012-10-18 14:28:25 UTC (rev 10263)
+++ trunk/phpgwapi/js/yahoo/common.js   2012-10-19 06:25:05 UTC (rev 10264)
@@ -198,24 +198,138 @@
        return pag;
 };
 
+
+YAHOO.portico.updateinlineTableHelper = function(container, requestUrl)
+{
+
+       var DatatableName = 'datatable_container' + container;
+       var PaginatorName = 'paginator_container' + container;
+
+       requestUrl = requestUrl ? requestUrl : 
YAHOO.portico.requestUrl.DatatableName;
+
+       var callback =
+       {
+               success: function(o)
+               {
+                       values_ds = JSON.parse(o.responseText);
+
+                       if(values_ds && values_ds['sessionExpired'] == true)
+                       {
+                               window.alert('sessionExpired - please log in');
+                               return;
+                       }
+
+                       
YAHOO.portico.Paginator.PaginatorName.setRowsPerPage(values_ds.ResultSet.Result.length,true);
+
+                       //delete values of datatable
+                       
YAHOO.portico.DataTable.DatatableName.getRecordSet().reset();
+
+                       //reset total records always to zero
+                       
YAHOO.portico.Paginator.PaginatorName.setTotalRecords(0,true);
+
+                       //obtain records of the last DS and add to datatable
+                       var record = values_ds.ResultSet.Result;
+                       var newTotalRecords = 
values_ds.ResultSet.totalResultsAvailable;
+
+                       if(record.length)
+                       {
+                               
YAHOO.portico.DataTable.DatatableName.addRows(record);
+                       }
+                       else
+                       {
+                               YAHOO.portico.DataTable.DatatableName.render();
+                       }
+
+                       //update paginator with news values
+                       
YAHOO.portico.Paginator.PaginatorName.setTotalRecords(newTotalRecords,true);
+
+                       if(typeof(values_ds.ResultSet.results) == 'undefined')
+                       {
+                               var results = 10;
+                       }
+                       else
+                       {
+                               var results = values_ds.ResultSet.results;
+                       }
+                               
+                       var activePage = 
Math.floor(values_ds.ResultSet.startIndex / results) + 1;
+                       
YAHOO.portico.Paginator.PaginatorName.setPage(activePage,true); //true no 
fuerza un recarge solo cambia el paginator
+
+                       //update "sortedBy" values
+
+                       values_ds.ResultSet.sortDir == "asc"? dir_ds = 
YAHOO.widget.DataTable.CLASS_ASC : dir_ds = YAHOO.widget.DataTable.CLASS_DESC;
+                       
YAHOO.portico.DataTable.DatatableName.set("sortedBy",{key:values_ds.ResultSet.sortKey,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.inlineTableHelper = function(container, url, colDefs, options, 
disablePagination) {
+
+       var DatatableName = 'datatable_container' + container;
+       var PaginatorName = 'paginator_container' + container;
        var Dom = YAHOO.util.Dom;
-       
+
+       if(typeof(YAHOO.portico.Paginator) == 'undefined' || 
!YAHOO.portico.Paginator )
+       {
+               YAHOO.portico.Paginator = {};
+       }
+
+       if(typeof(YAHOO.portico.DataTable) == 'undefined' || 
!YAHOO.portico.DataTable )
+       {
+               YAHOO.portico.DataTable = {};
+       }
+
+       if(typeof(YAHOO.portico.requestUrl) == 'undefined' || 
!YAHOO.portico.requestUrl )
+       {
+               YAHOO.portico.requestUrl = {};
+       }
+
        var container = Dom.get(container);
-       if(!disablePagination) {
+       if(!disablePagination)
+       {
+
+               if ( container.hasChildNodes() )
+               {
+                       while ( container.childNodes.length >= 1 )
+                   {
+                       container.removeChild( container.firstChild );
+                   }
+               }
+
                var paginatorContainer = 
container.appendChild(document.createElement('div'));
                var dataTableContainer = 
container.appendChild(document.createElement('div'));
        }
-       else {
+       else
+       {
                dataTableContainer = container;
        }
        options = options || {};
        options.dynamicData = true;
        
-       if(!disablePagination) {
+       if(!disablePagination)
+       {
                options.paginator = 
YAHOO.portico.setupInlineTablePaginator(paginatorContainer);
                url += '&results=' + options.paginator.getRowsPerPage() + '&';
+
+
+               YAHOO.portico.Paginator.PaginatorName =options.paginator;
        }
+
+
+//    options.sortedBy = {key:"id", dir:YAHOO.widget.DataTable.CLASS_ASC}; // 
Sets UI initial sort arrow
+
        var myDataSource = new YAHOO.util.DataSource(url);
        myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
        myDataSource.connXhrMode = "queueRequests";
@@ -245,6 +359,10 @@
                
                return data;
        };
+
+       YAHOO.portico.DataTable.DatatableName = myDataTable;
+       YAHOO.portico.requestUrl.DatatableName = url;
+
        return {dataTable: myDataTable, dataSource: myDataSource};
 };
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]