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

Prevent a row from appearing as selected (no highlighting)

5 Answers 42 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Marcus Kellermann
Top achievements
Rank 1
Marcus Kellermann asked on 08 Jun 2011, 10:15 PM
How do you prevent a row from appearing as selected when you check the checkbox on a selection column.  Basically I don't want the row to become highlighted I want it to appear as a standard row would appear.    I tried setting <SelectedItemStyle CssClass="rgRow"/> but that  has no effect. 

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 09 Jun 2011, 06:41 AM
Hello Marcus,

If you dont want the Grid row to be selected when clickiing on the CheckBox, then you can use CheckBox inside GridTemplateColumn instead of using GridCheckBoxColumn.

ASPX:
<Columns>
      <telerik:GridTemplateColumn>
           <ItemTemplate>
               <asp:CheckBox ID="CheckBox1" runat="server" />
           </ItemTemplate>
       </telerik:GridTemplateColumn>
   </Columns>

-Shinu.
0
Marcus Kellermann
Top achievements
Rank 1
answered on 09 Jun 2011, 11:47 AM
Sorry, my original post was unclear.  I want / need the row to be selected as I am relying on the Selected Rows collection and I don't want to require an edit of each row in order to select the field.   I am simply looking to visually not change the appearance of the selected row.
0
Radoslav
Telerik team
answered on 09 Jun 2011, 12:38 PM
Hello Marcus,

Please try using the following code snippet and let me know if it helps you:
<telerik:RadCodeBlock runat="server">
            <script type="text/javascript">
                function OnRowSelected(sender, eventArgs)
                {
                    var row = sender.get_masterTableView().get_dataItems()[eventArgs.get_itemIndexHierarchical()].get_element();
                    row.className = row.className.replace(" rgSelectedRow","");
                }
            </script>
        </telerik:RadCodeBlock>
<telerik:RadGrid ID="RadGrid1" runat="server" AllowMultiRowSelection="true">
        <MasterTableView>
            <Columns>
                ...
                <telerik:GridClientSelectColumn></telerik:GridClientSelectColumn>
            </Columns>
        </MasterTableView>
        <ClientSettings>
            <Selecting AllowRowSelect="true" />
            <ClientEvents OnRowSelected="OnRowSelected" />
        </ClientSettings>
    </telerik:RadGrid>

Looking forward for your reply.

All the best,
Radoslav
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Marcus Kellermann
Top achievements
Rank 1
answered on 09 Jun 2011, 01:16 PM
Yes that accomplished what I am looking for the only issue now is that if the rows are "Pre-Selected" server side then there are some visual issues.  Namely the scroll bar on the right extends into the header region and the Items list extends past the boundaries of the control.  See the attached image.

We "Pre-Select" the items server side with the following code.  In order to keep the rows from appearing selected on the initial load I had to change the CssClass server side as well.

protected void dgApplications_itemDataBound(object sender, GridItemEventArgs e)
    {
    if (!Page.IsPostBack)
        {
        switch (e.Item.ItemType)
            {  
            case GridItemType.AlternatingItem:
                e.Item.Selected = true;
                e.Item.CssClass = "rgAltRow";
                break;
 
            case GridItemType.Item:
                e.Item.Selected = true;
                e.Item.CssClass = "rgRow";
                break;
            }
        }
    }
0
Radoslav
Telerik team
answered on 14 Jun 2011, 08:58 AM
Hello Marcus,

It is hard to say what is causing the described issue without reproduce it on my side. Could you please post your aspx markup code with the related code behind. Thus I will be able to create a small project based on them, debug it and provide a solution.

Looking forward for your reply.

Regards,
Radoslav
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Grid
Asked by
Marcus Kellermann
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Marcus Kellermann
Top achievements
Rank 1
Radoslav
Telerik team
Share this question
or