filter grid with <form> element

Hi,



I am suing the grid filter function filterBy with the form element. I have implemented the filter funciton using dhtmlXGridFromTable and the table is populated from the database.

When I click on the button to fitler the table for given value, it scans the grids very quickly and then brings back the original values. When I remove the form element it works fine but i need the to be there.



Please suggest what is the workaround for this.

When I click on the button to fitler the table for given value, it scans the grids very quickly
It possible that clicking of the button triggers the form submit, which causes the issue in your case. ( the grid itself can’t cause such behavior)

You can try to update code of button as


Thanks for sending me the answer, I have tried the scipts, but it did not change anything. It  does not filter by grid and I want to filter multiple rows by doing the following;

        // search by Org Type
myGrid.filterBy(0,document.getElementById(“searchText”).value);
         // search by Org Name
myGrid.filterBy(1,document.getElementById(“searchText”).value,true);
        // search by Org Acronym
myGrid.filterBy(2,document.getElementById(“searchText”).value,true);

It does not wrok, what I would like to do is, First I filter by Organization type, then filter the result further by organization name, or acronym, or the other way around.

Please suggest,

thanks for your help as usual.

Javed


The filtering will use AND logic for all used filters, so it will filter rows where


type contains searchText AND name contains searchText AND acronym contains searchText

If you need to use OR logic, you need to use custom fuction as filter value.( works only in latest builds - please contact us directly at support@dhtmlx.com if you need an update )

var text = document.getElementById(“searchText”).value;
grid.filterBy(0,function(value,id){
if ( grid.cells(id,0).getValue().toString().toLowerCase().indexOf(text) != -1) return true;
if ( grid.cells(id,1).getValue().toString().toLowerCase().indexOf(text) != -1) return true;
if ( grid.cells(id,2).getValue().toString().toLowerCase().indexOf(text) != -1) return true;
return false;
});