Question

Photo of Taylor Cavaletto

1

Grid not firing OnRowSelected

I have this grid as laid out in the code below. When I select a row, it never fires my gList_ExpandRow method. Any ideas?

<div class="grid grid-panel">
                    <Rock:Grid ID="gList" runat="server"  DisplayType="Full" OnRowSelected="gList_ExpandRow"  OnRowDataBound="gList_RowDataBound">
                        <Columns>
                            <asp:BoundField DataField="Id" />
                            <asp:TemplateField SortExpression="SubmitForDate" HeaderText="Report">
                                <ItemTemplate>
                                    <asp:Literal ID="lSubmitForDate" runat="server" />
                                </ItemTemplate>
                            </asp:TemplateField>

                            <asp:TemplateField SortExpression="Score" HeaderText="Score">
                                <ItemTemplate>
                                    <asp:Literal ID="lScore" runat="server" />
                                </ItemTemplate>
                            </asp:TemplateField>

                            <asp:TemplateField SortExpression="Percent" HeaderText="Percent">
                                <ItemTemplate>
                                    <asp:Literal ID="lPercent" runat="server" />
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                    </Rock:Grid>
                </div>

  • Photo of Rock RMS

    0

    It appears the Rock grid only adds the needed 'data-row-index' css attribute to the table rows when at least one datakey is provided for the grid. We've updated the grid so that it always adds the attribute. However, it's probably good practice when binding to a list of entity items, to always add the "Id" as the datakey ( in code-behind: gList.DataKeyNames = new string[] { "id" }; ).

  • Photo of Nick Airdo

    0

    I was able to replicate the problem you're seeing and was able to get it to invoke your gList_ExpandRow method but I had to add a DataKeyNames="Id" property to your Grid markup. I'm not 100% sure what's going on behind the scenes that would be preventing the method from firing when it's not there... perhaps someone smarter than I knows that answer.