<script>
var max, max2;
///////////////////////////////////////////////////////
function filter3(objS, searchcriteria, Xcol){
searchcriteria=searchcriteria.toUpperCase();
var fmatch;
if(searchcriteria==''){
objS.setRowCount(max2);
objS.setRowIndices('');
objS.setTimeout(function(){
objS.selectRow(-1);
objS.setScrollTop(0);
},800);
}
if(searchcriteria!=''){
fmatch = [];
fmatch = -1 ;
for (var rw=0; rw<max2; rw++){
if ( objS.getCellValue(Xcol, rw).toUpperCase().indexOf(searchcriteria) >-1 ){
fmatch = rw;
break;
}
}
}
objS.setTimeout(function(){
if(fmatch !=-1){
objS.selectRow(fmatch);
objS.setScrollTop(fmatch*18);
}
},800);
}
var obj3 = new AW.Grid.Extended;
obj3.setCellText(function(i, j){return j + "-" + i});
obj3.setHeaderText(["header1", "header2", "header3", "header4", "header5", "header6", "header7", "header8", "header9", "header10"], 0);
obj3.setHeaderCount(2);
obj3.setFixedLeft(0);
obj3.getHeadersTemplate(1, "center").setStyle('background', 'lightyellow');
obj3.setColumnCount(10);
obj3.setRowCount(100);
obj3.onHeaderClicked = function(event, col, header) {
if (header == 1) {
obj3.setHeaderText('', 0);
var inp = new AW.UI.Input;
inp.setStyle('background', 'lightyellow');
inp.getContent('box/text').setStyle('color', 'green');
obj3.setHeaderTemplate(inp, col, 1);
obj3.getHeaderTemplate(col, 1).onControlEditEnded = function() {
var text = this.getControlText();
obj3.setHeaderTemplate(new AW.Grid.Header, col, 1);
obj3.setHeaderText(text, col, 1);
obj3.getHeaderTemplate(col, 1).getContent('box/text').setStyle('color', 'green');
var scrollLeft = obj3.getViewTemplate("box", "top", "center").element().scrollLeft;
obj3.getHeadersTemplate(1, "center").refresh();
obj3.getViewTemplate("box", "top", "center").element().scrollLeft = scrollLeft;
max = obj3.getRowCount();
max2 = max;
if(text !=''){ filter3(obj3,text,col); }
}
var scrollLeft = obj3.getViewTemplate("box", "top", "center").element().scrollLeft;
obj3.getHeadersTemplate(1, "center").refresh();
obj3.getViewTemplate("box", "top", "center").element().scrollLeft = scrollLeft;
obj3.getHeaderTemplate(col, 1).focus();
}
}
document.write(obj3);
input1.onControlValidated = function(text){
var i, rows = [], max = obj.getRowCount();
for (i=0; i<max; i++){
if (obj.getCellValue(1, i) < 20000){
rows.push(i);
alert(obj.getCellValue(1, i));
}
}
obj.setScrollTop(200 * 18);
}
input1.onControlValidated = function(text){
var i, rows = [], max = obj.getRowCount();
for (i=0; i<max; i++){
if (obj.getCellValue(0, i).toLowerCase().search(text.toLowerCase()) > -1){
obj.selectRow(i);
obj.setScrollTop(i * 18);
}
}
}
input1.onControlValidated = function(text){
var i, rows = [], max = obj.getRowCount();
for (i=0; i<max; i++){
if (obj.getCellValue(0, i).toLowerCase().search(text.toLowerCase()) > -1){
obj.selectRow(i);
obj.setScrollTop(i * 18);
//SHOW COLUMN
}else{
//SINCE NO MATCH HIDE COLUMN
}
}
}
var totcols=obj.getColumnCount();
function searchwithhideshow(text, col){
var visiblecolmatch=[];
var visiblecolNOmatch=[];
for (k=0; k<totcols; k++){
visiblecolmatch[k]=k;
if (col<k){ visiblecolNOmatch[k] = k}
if ( col>k){ visiblecolNOmatch[k-1] = k }
}
var i, rows = [], max = obj.getRowCount();
for (i=0; i<max; i++){
if (obj.getCellValue(col,i).toLowerCase().search(text.toLowerCase()) > -1){
obj.selectRow(i);
obj.setScrollTop(obj.getRowPosition(i) * 18);
//SHOW COLUMN
obj.setColumnCount(totcols);
obj.setColumnIndices(visiblecolmatch);
}else{
//SINCE NO MATCH HIDE COLUMN
obj.setColumnCount(totcols-1);
obj.setColumnIndices(visiblecolNOmatch);
}
obj.refresh();
}
}
input1.onControlValidated = function(text){
searchwithhideshow(text, 1) }
var totcols=obj.getColumnCount();
function searchwithhideshow(text, col){
var visiblecolmatch=[];
var visiblecolNOmatch=[];
for (k=0; k<totcols; k++){
visiblecolmatch[k]=k;
if (k<col){ visiblecolNOmatch[k] = k} //////
if ( k>col){ visiblecolNOmatch[k-1] = k } //////
}
var i, rows = [], max = obj.getRowCount();
for (i=0; i<max; i++){
if (obj.getCellValue(col,i).toLowerCase().search(text.toLowerCase()) > -1){
obj.selectRow(i);
obj.setScrollTop(obj.getRowPosition(i) * 18);
//SHOW COLUMN
obj.setColumnCount(totcols);
obj.setColumnIndices(visiblecolmatch);
}else{
//SINCE NO MATCH HIDE COLUMN
obj.setColumnCount(totcols-1);
obj.setColumnIndices(visiblecolNOmatch);
}
}
obj.refresh(); //////
}
input1.onControlValidated = function(text){
searchwithhideshow(text, 1) }
var SearchBox = new AW.UI.Input;
SearchBox.setStyle("Width","250px");
var Search = new AW.UI.Button;
Search.setStyle('width','100px');
Search.setControlText('Search');
var C,R,Rc;
C = 0; //Sets the Column Count to Zero
R = 0; //Sets the Row Count to Zero
Rc = grd.getRowCount(); //Gets the Total number of rows
Search.onControlClicked = function(event){
var searchText = SearchBox.getControlText();
if(searchText=='') {alert(searchText+' Not Found!'); return false;}
for( r=R;r<Rc;r++) {
R = r;
for(var c=C;c<2;c++) {
var cellContent=grd.getCellText(c,r);
var pos=cellContent.indexOf(searchText);
if(pos !=-1) {
var desc = grd.getCellText(1,r);
grd.setSelectionMode("single-row");
grd.setSelectedRows([r]);
grd.setCurrentRow(r);
grd.setScrollTop( r * grd.getRowHeight());
//alert(R + '-' + C);
R ++;
C = 0;
return false;
}
}
}
alert('Search Finished');
R = 0;
}
var max, max2;
function filter3(objS, searchcriteria, Xcol){
searchcriteria=searchcriteria.toUpperCase();
var rows=[];
if(searchcriteria!=''){
for (var rw=0; rw<max2; rw++){
if ( objS.getCellValue(Xcol, rw).toUpperCase().indexOf(searchcriteria) >-1 ){
rows.push(rw);
}
}
}
objS.setTimeout(function(){
if(searchcriteria==''){
objS.setRowCount(max2);
objS.setRowIndices('');
objS.getRowsTemplate().refresh();
}
if(searchcriteria !=''){
if(rows.length >0){
objS.setRowCount(rows.length);
objS.setRowIndices(rows);
objS.getRowsTemplate().refresh();
}
else{
objS.setRowCount(max2);
objS.setRowIndices('');
objS.getRowsTemplate().refresh();
alert('no match');
objS.setHeaderText('',Xcol,1);
obj3.getHeadersTemplate(1, "center").refresh();
}
}
},200);
}
var obj3 = new AW.Grid.Extended;
obj3.setCellText(function(i, j){return j + "-" + i});
obj3.setHeaderText(["header1", "header2", "header3", "header4", "header5", "header6", "header7", "header8", "header9", "header10"], 0);
obj3.setHeaderCount(2);
obj3.setFixedLeft(0);
obj3.getHeadersTemplate(1, "center").setStyle('background', 'lightyellow');
obj3.setColumnCount(10);
obj3.setRowCount(100);
obj3.onHeaderClicked = function(event, col, header) {
if (header == 1) {
obj3.setHeaderText('', 0);
var inp = new AW.UI.Input;
inp.setStyle('background', 'lightyellow');
inp.getContent('box/text').setStyle('color', 'green');
obj3.setHeaderTemplate(inp, col, 1);
obj3.getHeaderTemplate(col, 1).onControlEditEnded = function() {
var text = this.getControlText();
obj3.setHeaderTemplate(new AW.Grid.Header, col, 1);
obj3.setHeaderText(text, col, 1);
obj3.getHeaderTemplate(col, 1).getContent('box/text').setStyle('color', 'green');
var scrollLeft = obj3.getViewTemplate("box", "top", "center").element().scrollLeft;
obj3.getHeadersTemplate(1, "center").refresh();
obj3.getViewTemplate("box", "top", "center").element().scrollLeft = scrollLeft;
if(text !=''){ filter3(obj3,text,col); }
if(text ==''){ filter3(obj3,'',col); }
}
var scrollLeft = obj3.getViewTemplate("box", "top", "center").element().scrollLeft;
obj3.getHeadersTemplate(1, "center").refresh();
obj3.getViewTemplate("box", "top", "center").element().scrollLeft = scrollLeft;
obj3.getHeaderTemplate(col, 1).focus();
}
}
max = obj3.getRowCount();
max2 = max;
document.write(obj3);
This topic is archived.