Преглед изворни кода

#770 and #853: When a list is configured directly from the table (NOT from the Dialog box), then these settings are not kept neither when creating a shortcut nor when opening the "configure this list" dialog

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@3030 a333f486-631f-4898-b8df-5754b55c2be0
romainq пре 11 година
родитељ
комит
77e608b627
2 измењених фајлова са 41 додато и 0 уклоњено
  1. 32 0
      js/datatable.js
  2. 9 0
      js/jquery.tablesorter.pager.js

+ 32 - 0
js/datatable.js

@@ -240,6 +240,38 @@ $(function()
 			// in 1.9 would use _super
 			this._superApply(arguments);
 		},
+		UpdateState: function( config )
+		{
+			var iPageSize = config.page_size;
+			if (iPageSize == -1)
+			{
+				iPageSize = 0;
+			}
+			this.options.iPageSize = iPageSize;
+
+			var iPos = 0;
+			for (alias in this.options.oColumns)
+			{
+				for (attcode in this.options.oColumns[alias])
+				{
+					this.options.oColumns[alias][attcode]['sort'] = 'none';
+					if (this.options.oColumns[alias][attcode]['checked'])
+					{
+						if (iPos == config.sort_index)
+						{
+							this.options.oColumns[alias][attcode]['sort'] = config.sort_order;
+						}
+						iPos++;
+					}
+				}
+			}
+
+			var sId = new String(this.element.attr('id'));
+			var sListId = sId.replace('datatable_', '');
+			var dlgElement = $('#datatable_dlg_'+sListId);
+			dlgElement.find('input[name=page_size]').val(iPageSize);
+			dlgElement.find(':itop-fieldsorter').fieldsorter('option', { fields: this.options.oColumns });
+		},
 		_saveDlgState: function()
 		{
 			this.originalState = {};

+ 9 - 0
js/jquery.tablesorter.pager.js

@@ -176,6 +176,15 @@ function sprintf(format, etc) {
 					s_col = s[0];
 					s_order = (s[1] == 0) ? 'asc' : 'desc';
 				}
+
+				var oDataTable = $(table).closest('table.itop-datatable');
+				var oConfig = {
+					sort_index: s_col,
+					sort_order: s_order,
+					page_size: table.config.selectedSize
+				};
+				oDataTable.datatable('UpdateState', oConfig);
+
 				$('#loading', table.config.container).html('<img src="../images/indicator.gif" />');
 				table.ajax_request = $.post(AddAppContext(GetAbsoluteUrlAppRoot()+"pages/ajax.render.php"),
 						{ operation: 'pagination',