This is a migrated thread and some comments may be shown as answers.

Cannot highlight grid row and selectedindexchanged not firing

1 Answer 238 Views
Grid
This is a migrated thread and some comments may be shown as answers.
tcl4p
Top achievements
Rank 1
tcl4p asked on 11 Dec 2014, 08:56 PM
I have a radgrid that 1. I cannot highlight the row on clicking and 2. the selectedindexchanged event does not fire.  The grid sits inside an update panel and is loaded when a user select a value from a combo box, which is passed as a parameter to a stored procedure.  The grid load without problem, but as mentioned once loaded I cannot click on the row and highlight the row and the selectedindexchanged event does not fire.  Below is the grid settings.  I have also tried  to add the following code on the page load, but this has not helped.
 this.grdItems.ClientSettings.EnablePostBackOnRowClick = true;
this.grdItems.ClientSettings.Selecting.AllowRowSelect = true;

Any suggestions?

<telerik:RadGrid ID="grdItems" runat="server" CellSpacing="0"
                                      DataSourceID="SqlDataSource1" GridLines="None" Height="400px"
                                      AccessKeySkin="Office2010Black"
                                         onselectedindexchanged="grdItems_SelectedIndexChanged"
                                         Skin="Office2010Black">
                                         <clientsettings>
                                          <Scrolling AllowScroll="True" UseStaticHeaders="True" />
                                       <ClientEvents OnRowSelected="RowSelected" />
                                          <selecting AllowRowSelect="True" />
                                        </clientsettings>
                                        <mastertableview allowpaging="True" autogeneratecolumns="False"
                                         datakeynames="ID" datasourceid="SqlDataSource1" pagesize="14">
                                         <Columns>
                                            <telerik:GridBoundColumn DataField="ID" DataType="System.Int32" Display="False"
                                             FilterControlAltText="Filter ID column" HeaderText="ID" ReadOnly="True"
                                             SortExpression="ID" UniqueName="ID">
                                             </telerik:GridBoundColumn>
                                             <telerik:GridBoundColumn DataField="HoseID"
                                              FilterControlAltText="Filter HoseID column" HeaderText="Hose ID"
                                              ReadOnly="True" SortExpression="HoseID" UniqueName="HoseID">
                                              <HeaderStyle Font-Bold="True" Font-Size="Larger" />
                                             </telerik:GridBoundColumn>
                                         </Columns>
                                      </mastertableview>
                                     </telerik:RadGrid>

1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 16 Dec 2014, 11:22 AM
Hello,

The behavior that you are describing could be observed if there is a JavaScript error present on the page, which will prevent the proper work of the control. Please inspect your browser's console and see if such errors are present.

As for the server-side OnSelectedIndexChanged event, it will fire on row click only if the EnablePostBackOnRowClick is set to true.

Following is your RadGrid markup with dummy data, which fires the OnSelectedIndexChanged event correctly:
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
    <script type="text/javascript">
        function RowSelected(sender, args) {
 
        }
    </script>
</telerik:RadCodeBlock>
 
<telerik:RadGrid ID="grdItems" runat="server" CellSpacing="0"
    GridLines="None" Height="400px" OnNeedDataSource="grdItems_NeedDataSource"
    AccessKeySkin="Office2010Black"
    OnSelectedIndexChanged="grdItems_SelectedIndexChanged"
    Skin="Office2010Black">
    <ClientSettings EnablePostBackOnRowClick="true">
        <Scrolling AllowScroll="True" UseStaticHeaders="True" />
        <ClientEvents OnRowSelected="RowSelected" />
        <Selecting AllowRowSelect="True" />
    </ClientSettings>
    <MasterTableView AllowPaging="True" AutoGenerateColumns="False"
        DataKeyNames="ID" PageSize="14">
        <Columns>
            <telerik:GridBoundColumn DataField="ID" DataType="System.Int32" Display="False"
                FilterControlAltText="Filter ID column" HeaderText="ID" ReadOnly="True"
                SortExpression="ID" UniqueName="ID">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="HoseID"
                FilterControlAltText="Filter HoseID column" HeaderText="Hose ID"
                ReadOnly="True" SortExpression="HoseID" UniqueName="HoseID">
                <HeaderStyle Font-Bold="True" Font-Size="Larger" />
            </telerik:GridBoundColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>

And the code-behind:
protected void grdItems_SelectedIndexChanged(object sender, EventArgs e)
{
 
}
 
protected void grdItems_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
    DataTable table = new DataTable();
    table.Columns.Add("ID", typeof(int));
    table.Columns.Add("HoseID", typeof(string));
    for (int i = 0; i < 5; i++)
    {
        table.Rows.Add(i, i);
    }
 
    (sender as RadGrid).DataSource = table;
}


Best Regards,
Konstantin Dikov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
tcl4p
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or