3.2.0

help with find button

this url worked until I added a code section
http://proximityone.com/k12schools/azschools1.htm

The text added is listed below and is at the end of the script.
I have a similar "find in text" above this code that works properly.
I am seeking to have this addl "find in text" work on column 7, but it will not even allow the user to key in text to find.

Can someone tell me how to fix?

Thank you ... the errant code:

/////////////

var max_3 = table.getCount();
var max2_3 = max_3;

function filter3(searchcriteria3){
var i, rows = [], max_3 = obj.getRowCount();
if(searchcriteria3==''){
obj.setRowCount(max2_3);
obj.setRowIndices('');
}
if(searchcriteria3!=''){
for (i=0; i<max_3; i++){
if (obj.getCellValue(7, i).indexOf(searchcriteria3) >-1 ){
rows.push(i);
}
}
obj.setRowCount(rows.length);
obj.setRowIndices(rows);
}
}

var button3 = new AW.UI.Button;
button3.setControlText("Find in City Name:");
button3.onControlClicked = function(){ filter3( input3.getControlText()); }
document.write(button3);

var input3 = new AW.UI.Input;
input3.setId("myCombo");

input3.setControlText("enter text & click Find");
document.write(input3);
Warren
February 15,
>but it will not even allow the user to key in text to find.
Thats because input1 & input3 have the same ID,
input3.setId("myCombo");
so try to put different id's on both.

There is a missing refresh at the end of both filters:
/....
obj.setRowCount(rows.length);
obj.setRowIndices(rows);
}
obj.getRowsTemplate().refresh(); /// missing refresh
}


No need to use max_3 var again because is setted outside so:
so replace:
var i, rows = [], max_3 = obj.getRowCount();
with just:
var i, rows = [];


And you can use the same filter for both buttons by including the column to be searched in the function:
but remember to pass the second parameter like:
button3.onControlClicked = function(){ filter3( input3.getControlText(), 7 ); } /// 7 is the column parameter

var max_3 = table.getCount();
var max2_3 = max_3;

function filter3(searchcriteria3, column){
var i, rows = [];
if(searchcriteria3==''){
obj.setRowCount(max2_3);
obj.setRowIndices('');
}
if(searchcriteria3!=''){
for (i=0; i<max_3; i++){
if (obj.getCellValue(column, i).indexOf(searchcriteria3) >-1 ){
rows.push(i);
}
}
obj.setRowCount(rows.length);
obj.setRowIndices(rows);
}
obj.getRowsTemplate().refresh();
}


A nested ( filter on filtered rows ) filter function is also possible and not complicated for 2 filters, ( but not that easy for more than two), I'll try to post both soon.
HTH
Carlos
February 16,
Thank you! I would never have figured that out. :(

I modified the id and added the refresh and it works as I had hoped.

I do not see the benefits of the refresh but added anyway. :)

A nested filter function would be great; a task I cannot see through design or code wise.

There are a couple of other important filter columns (Distname is the most imporant third filter).

I very much appreciate your help. Thank you.
Warren
February 16,

This topic is archived.

See also:


Back to support forum