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(""); } } });
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
Hi Stamen,
here all definitions:
<link href="http://cdn-na.infragistics.com/jquery/20112/2045/themes/min/base/ig.ui.min.css" rel="stylesheet" type="text/css" /> <link href="http://cdn-na.infragistics.com/jquery/20112/2045/themes/min/ig/jquery.ui.custom.min.css" rel="stylesheet" type="text/css" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" type="text/javascript"></script> <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/jquery-ui.min.js" type="text/javascript"></script> <script src="http://cdn-na.infragistics.com/jquery/20112/2045/js/combined/min/ig.ui.min.js" type="text/javascript"></script> <script type="text/javascript" src="infragistics.core.js"></script> <script type="text/javascript" src="infragistics.lob.js"></script>
When I enter the procedure "searchCells(....)" an exception occurs in the for-statement "for(...; cellIndex < row.cells.length;...)" The message I've received is a javaScript runtime error. If I look to the object row it seems to be ok. But not rows.cells - it is undefined. At this point the code crashes.
Which jQuery is missing, what do you think?
Regards