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("");
                    }
                }
           });
   

Parents
  • 5513
    Offline posted

    Hello,

    Thank you for using Infragistics forums!

    From what I can see row is a member of allParentRows which is not defined in the code you pasted. My best guess is that allParentRows is actually a jQuery object and the code doesn't iterate it correctly.

    Try changing

    if (searchCells(allParentRows[rowIndex], searchValue)) {

    to

    if (searchCells(allParentRows.eq(rowIndex), searchValue)) {


    If you could provide me with the code responsible for assigning the value for allParentRows, I should be able to help further.

    Please, let me know if you have any other questions or concerns!

    Best regards,

    Stamen Stoychev

Reply Children