Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

Possible bug, I cannot clear all and add again columns to grid

$
0
0
Be sure your post includes:

1. Problem appears in smart client 10.0 and olders (we have noticed that in 8.3 version and 9 version too)

2. All browsers : chrome, mozilla and IE, newest versions.

3. There is no bug log, but problem appears on java script side. I have tried to remove all columns from list grid and it has worked, but when i have tried to add them again there was no filters in the grid. Redrawing and setting showFilterEditor to true not works.

6. Below there is a sample of code. I have added two buttons. One is responsible for selecting all columns, the second one for removing them from grid. After removing all, seleect all not works properly.

getColumnPickerItems : function() {
var allColumns = this.Super("getColumnPickerItems", arguments);
var notSortColumns = new Array();
for (var i = 0; i < allColumns.length; i++) {
//if (!this.getSortSpecifier(allColumns[i].fieldName)) {
notSortColumns.push(allColumns[i]);
//}
}
var grid = this;
notSortColumns.sort(function(a, b) {
return a.title.localeCompare(b.title);
});
var clearAllColumns = {
autoDismiss : false,
checkIf : function (target, menu, item) {
return false;
},
click : function(target, item, menu) {
if (menu.data) {
var fieldsToHide = new Array();
if (allColumns.size() == (notSortColumns.size()-3)) {
for (var i = 0; i < menu.data.length; i++) {
var gridColumn = menu.data[i];
if (gridColumn.fieldName !== undefined && gridColumn.checked){
fieldsToHide.push(gridColumn.fieldName);
}
}
} else {
for (var i = 0; i < menu.data.length; i++) {
var gridColumn = menu.data[i];
if ((gridColumn.fieldName != undefined) && gridColumn.checked && gridColumn.fieldName !='') {
fieldsToHide.push(gridColumn.fieldName);
}
}
}
fieldsToHide.shift();
grid.hideFields(fieldsToHide);
grid.setCriteria(null);
menu.body.delayCall("markForRedraw");
}

},
enableIf : function (target, menu, item) {
return true;
},
title : "CLEAR"
};
var selectAllColumns = {
autoDismiss : false,
checkIf : function (target, menu, item) {
return false;
},
click : function(target, item, menu) {
if (menu.data) {
var fieldsToShow = new Array();
for (var i = 0; i < menu.data.length; i++) {
var gridColumn = menu.data[i];
if ((gridColumn.fieldName != undefined) && !gridColumn.checked) {
fieldsToShow.push(gridColumn.fieldName);
}
}
grid.showFields(fieldsToShow);
grid.setCriteria(null);
menu.body.delayCall('markForRedraw',null,1000);
}
},
enableIf : function (target, menu, item) {
return true;
},
title : "SELECT ALL"
};
notSortColumns.add(clearAllColumns, 0);
notSortColumns.add(selectAllColumns, 1);
notSortColumns.add({isSeparator:true}, 2);
return notSortColumns;
}

Viewing all articles
Browse latest Browse all 4756

Trending Articles