Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
85
search full text in hierarchicalgrid
posted

Hi everybody,

has anyone a good example for a search-box function in hierachical grid? I have one parent-band and one child-band.

At the end, my code crashes a the bold marked code "row.cells", see below.

   
   

   
   
   

                //Events:

                $("#btnSearch").igButton({ labelText: $("#btnSearch").val() }).click(function () {
                    findRows($("#txtSearch").val());
                });

                $("#btnClear").igButton({ labelText: $("#btnClear").val() }).click(function () {
                    clearSearch();
                });

                function findRows(searchValue) {
                    parentGrid = $("#WebHierarchicalDataGrid1").igHierarchicalGrid("rootWidget");                                      
                    if ($.trim(searchValue).length > 0) {
                        for (var rowIndex = 0; rowIndex < allParentRows.length; rowIndex++) {
                            if (searchCells(allParentRows[rowIndex], searchValue)) {
                                if (!$("#hierarchicalGrid").igHierarchicalGrid("expanded", allParentRows[rowIndex])) {
                                    $("#hierarchicalGrid").igHierarchicalGrid("expand", allParentRows[rowIndex]);
                                }
                            } else {
                                if ($("#hierarchicalGrid").igHierarchicalGrid("expanded", allParentRows[rowIndex])) {
                                    $("#hierarchicalGrid").igHierarchicalGrid("collapse", allParentRows[rowIndex]);
                                }
                            }
                        }
                    } else {
                        clearSearch();
                    }
                }

                function searchCells(row, searchCellValue) {                                      
                    for (var cellIndex = 1; cellIndex < row.cells.length; cellIndex++) {                    
                        var cellValue = " " + $(row.cells[cellIndex]).html() + " ";
                        if (cellValue.toLowerCase().indexOf(searchCellValue.toLowerCase()) >= 0) {
                            return true;
                        }
                    }
                    return false;
                }

                function clearSearch() {
                    for (var rowIndex = 0; rowIndex < allParentRows.length; rowIndex++) {
                        if ($("#hierarchicalGrid").igHierarchicalGrid("expanded", allParentRows[rowIndex])) {
                            $("#hierarchicalGrid").igHierarchicalGrid("collapse", allParentRows[rowIndex]);
                        }
                        $("#inpSearch").val("");
                    }
                }
           });