dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #20168
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9093: Fix Tabular sorting bug.
------------------------------------------------------------
revno: 9093
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-11-21 14:36:34 +0700
message:
Fix Tabular sorting bug.
modified:
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js 2012-11-14 12:52:15 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js 2012-11-21 07:36:34 +0000
@@ -666,7 +666,7 @@
orderByOrgunitAsc: true,
orderByExecutionDateByAsc: true,
orgunitIds: [],
- generateReport: function( type ) {
+ generateReport: function( type, isSorted ) {
// Validation
if( !this.validation.objects() )
{
@@ -677,7 +677,7 @@
// Export to XLS
if( type)
{
- window.location.href = url + "?" + this.getURLParams(type);
+ window.location.href = url + "?" + this.getURLParams(type, isSorted );
}
// Show report on grid
else
@@ -687,31 +687,34 @@
url: url,
method: "POST",
scope: this,
- params: this.getParams(),
+ params: this.getParams(isSorted),
success: function(r) {
var json = Ext.JSON.decode(r.responseText);
if(json.message!=""){
TR.util.notification.error(TR.i18n.error, json.message);
}
else{
- TR.state.total = json.total;
- TR.state.totalRecords = json.totalRecords
- TR.value.columns = json.columns;
- TR.value.values = json.items;
-
- // Get fields
- var fields = [];
- fields[0] = 'id';
- for( var index=1; index < TR.value.columns.length; index++ )
- {
- fields[index] = 'col' + index;
- }
- TR.value.fields = fields;
-
- // Set data for grid
- TR.store.getDataTableStore();
- TR.datatable.getDataTable();
-
+ if( isSorted ){
+ TR.store.datatable.loadData(TR.value.values,false);
+ }
+ else{
+ TR.state.total = json.total;
+ TR.state.totalRecords = json.totalRecords
+ TR.value.columns = json.columns;
+ TR.value.values = json.items;
+ // Get fields
+ var fields = [];
+ fields[0] = 'id';
+ for( var index=1; index < TR.value.columns.length; index++ )
+ {
+ fields[index] = 'col' + index;
+ }
+ TR.value.fields = fields;
+
+ // Set data for grid
+ TR.store.getDataTableStore();
+ TR.datatable.getDataTable();
+ }
TR.datatable.setPagingToolbarStatus();
}
TR.util.mask.hideMask();
@@ -744,7 +747,7 @@
}
});
},
- getParams: function() {
+ getParams: function(isSorted) {
var p = {};
p.startDate = TR.cmp.settings.startDate.rawValue;
p.endDate = TR.cmp.settings.endDate.rawValue;
@@ -763,7 +766,7 @@
// Get searching values
p.searchingValues = [];
- if( !TR.state.paramChanged() )
+ if( !TR.state.paramChanged() || isSorted )
{
var cols = TR.datatable.datatable.columns;
for( var k in cols )
@@ -787,7 +790,7 @@
}
return p;
},
- getURLParams: function( type ) {
+ getURLParams: function( type, isSorted ) {
var p = "";
p += "startDate=" + TR.cmp.settings.startDate.rawValue;
p += "&endDate=" + TR.cmp.settings.endDate.rawValue;
@@ -803,7 +806,7 @@
p += '&orgunitIds=' + TR.state.orgunitIds[i];
}
- if( !TR.state.paramChanged() )
+ if( !TR.state.paramChanged() || isSorted )
{
var cols = TR.datatable.datatable.columns;
for( var k in cols )
@@ -1339,8 +1342,8 @@
};
TR.exe = {
- execute: function( type ) {
- TR.state.generateReport( type );
+ execute: function( type, isSorted ) {
+ TR.state.generateReport( type, isSorted );
},
filter: function() {
TR.state.isFilter = true;
@@ -2032,7 +2035,7 @@
id: 'btnSortBy',
disabled: true,
execute: function() {
- TR.exe.execute();
+ TR.exe.execute(false, true );
},
listeners: {
afterrender: function(b) {