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
forgot something:
definition of allParentRows is: allParentRows = parentGrid.igHierarchicalGrid("allRows");
Is that the devil of it? See bold letters.
Please, have in mind that we no longer support version 11.2 as indicated here: http://ko.infragistics.com/support/product-lifecycle so I may not be able to provide adequate help with this matter.
With this said, I looked through igHierarchicalGrid's code for 11.2.2045 and it doesn't have a method "allRows" defined. This is a method from igGrid's API. Since you are using an older jQuery UI version, this inaccurate API call probably fails silently. You should try changing igHierarchicalGrid with igGrid when defining allParentRows.