3.2.0

search column for string

I have a 2.5.1 application working and seek to add a button and input box under grid. Below is the code being used. Something is wrong.

In this simple app I set the variable text1 to a 3 char string. when the user clicks button1, I want the grid to display only rows where the value of text1 -- as entered by the user -- appear in the grid.

I have something out of sequence? Can someone help?

actually my interest is to then generalize this:
table.getData(4, i).substr(0,3) == text1.substr(0,3)
so that the full string table.getData(4, i) is searched for the exact characters text1.

Thank you.

======>
var text1 =" Al";

function showselected1(){
var i, rows = [];
var max = table.getCount();

for (i=0; i<max; i++){
if (table.getData(4, i).substr(0,3) == text1.substr(0,3)){
rows.push(i);
}
}
obj.clearRowModel();
obj.clearSortModel();
obj.clearScrollModel();

obj.setRowCount(rows.length);
obj.setRowIndices(rows);
}

var button1 = new AW.UI.Button;
button1.setControlText("Find in Name:");
button1.onClick = showselected1;
document.write(button1);

var input1 = new AW.UI.Input;
input1.setControlText(text1);
document.write(input1);
Dave
April 10,
You can use indexOf() method instead of comparing substrings -

http://msdn2.microsoft.com/en-us/library/53xtt423.aspx

i.e.

if (table.getData(4, i).indexOf(text1) > -1 ){
rows.push(i);
}
Alex (ActiveWidgets)
April 10,
Thank you. I have looked and cannot see that this would work.

As an example, the value of text1 might be "NV" (entered by the user in the input box). Clicking button1 should then show all rows that have the text NV anywhere in the cell in column 4.

there must be an example somewhere?
Dave
April 10,

This topic is archived.

See also:


Back to support forum