I need to hide certain cell buttons in a grid.
I can do it as long as the buttons are in the first band (I followed this example http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.Aspx?ArticleID=5218)
The datasource I'm binding to has 2 bands and the buttons are in the child band. I've tried various client side event handlers to try and loop through the row in a similar manner to the example, but I can never get a reference to the child rows. Does anyone know how to do this?
Hello,
Yes, I think I know what is going on. Starting from getting the grid instance (similar to what is shown in the DevCenter KB article)
var grid = igtbl_getGridById( gridName );
You now have the client-side object of the grid and can loop through its rows, but this applies only for the master table. However, you can use the "getChildRows()" method of each row of the master grid to obtain if it has any child rows - if it does - you can execute the same logic for them as well:
More info on the CSOM getChildRows() method can be found here:
http://help.infragistics.com/Help/NetAdvantage/NET/2008.2/CLR2.0/html/WebGrid_row_Object_CSOM.html
Please, let me know if this helps.
I did try this, but a count on the getChildRows object always returned zero (I know there are always at least 3 child rows to every parent row)
Here is the code I used
function UltraGrid1_InitializeLayoutHandler(gridName){ var grid = igtbl_getGridById( gridName ); var row; for( i = 0; i < grid.Rows.length; ++i ) { row = grid.Rows.getRow(i); for( j = 0; j < row.getChildRows.length; ++j ) { alert(j); var childRow = row.getChildRow(j) var btn = childRow.getCellFromKey("Button"); var hidden = btn.getValue(); if (hidden == "hidden") { btn.Element.style.visibility = "hidden"; } } }}
Thanks for the follow-up. Your approach seems perfectly valid and the code looks great, the only thing that was missing was the braces next to calling getChildRows, because it is a function. So please just change
for( j = 0; j < row.getChildRows.length; ++j )
to
for( j = 0; j < row.getChildRows().length; ++j )
and this should address the issue.
The problem is the UltraWebGrid "gulps" errors inside client-side event handlers, hence instead of error you probably just got nothing. This is really not good experience, I know, so I can suggest one javascript debugging technique that may make it easier for you to write client side code against our CSOM:
http://forums.infragistics.com/forums/p/5669/25150.aspx#25150
(the second post in the thread)
Thanks, this sorted things out for me. The debugging technique will definately help in future.